]> Git — Sourcephile - comptalang.git/blob - jcc/Hcompta/Format/JCC/Unit.hs
Ajout : Hcompta.Format.JCC.
[comptalang.git] / jcc / Hcompta / Format / JCC / Unit.hs
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE FlexibleInstances #-}
4 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
5 {-# LANGUAGE OverloadedStrings #-}
6 {-# LANGUAGE StandaloneDeriving #-}
7 {-# LANGUAGE TypeFamilies #-}
8 {-# OPTIONS_GHC -fno-warn-orphans #-}
9 module Hcompta.Format.JCC.Unit where
10
11 import Control.DeepSeq
12 import Data.Data
13 import Data.Eq (Eq(..))
14 import Data.Ord (Ord(..))
15 import Data.String (IsString)
16 import Data.Text (Text)
17 import qualified Data.Text as Text
18 import Data.Typeable ()
19 import Prelude ((.), Int)
20 import Text.Show (Show(..))
21
22 import qualified Hcompta.Unit as Unit
23
24 -- * Type 'Unit'
25
26 newtype Unit = Unit Text
27 deriving (Data, Eq, IsString, Ord, Show, Typeable)
28 instance Unit.Unit Unit where
29 unit_empty = Unit ""
30 unit_text (Unit t) = t
31 instance NFData Unit where
32 rnf (Unit t) = rnf t
33
34 unit_length :: Unit -> Int
35 unit_length = Text.length . Unit.unit_text