]> Git — Sourcephile - comptalang.git/blob - lib/Hcompta/Amount/Unit.hs
Correction : compatiblité avec GHC-7.6 en limitant l’usage de Prelude.
[comptalang.git] / lib / Hcompta / Amount / Unit.hs
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
3 {-# LANGUAGE OverloadedStrings #-}
4 module Hcompta.Amount.Unit where
5
6 import Control.DeepSeq
7 import Data.Data
8 import Data.Eq (Eq(..))
9 import Data.Ord (Ord(..))
10 import Data.String (IsString)
11 import qualified Data.Text as Text
12 import Data.Text (Text)
13 import Data.Typeable ()
14 import Prelude ((.), Int, Show(..))
15
16 newtype Unit
17 = Unit Text
18 deriving (Data, Eq, IsString, Ord, Show, Typeable)
19 instance NFData Unit where
20 rnf (Unit t) = rnf t
21
22 -- NOTE: maybe consider using text-show package
23 text :: Unit -> Text
24 text (Unit t) = t
25
26 nil :: Unit
27 nil = Unit ""
28
29 length :: Unit -> Int
30 length = Text.length . text