]> Git — Sourcephile - comptalang.git/blob - lib/Hcompta/Amount/Unit.hs
Polissage : Lib.Parsec : espaces.
[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.String (IsString)
9 import qualified Data.Text as Text
10 import Data.Text (Text)
11 import Data.Typeable ()
12
13 newtype Unit
14 = Unit Text
15 deriving (Data, Eq, IsString, Ord, Show, Typeable)
16 instance NFData Unit where
17 rnf (Unit t) = rnf t
18
19 -- NOTE: maybe consider using text-show package
20 text :: Unit -> Text
21 text (Unit t) = t
22
23 nil :: Unit
24 nil = Unit ""
25
26 length :: Unit -> Int
27 length = Text.length . text