]> Git — Sourcephile - comptalang.git/blob - lib/Hcompta/Amount/Unit.hs
Modif : aplatit Hcompta.{Format => } et Hcompta.{Calc => }.
[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 Data.Data
7 import Data.String (IsString)
8 import qualified Data.Text as Text
9 import Data.Text (Text)
10 import Data.Typeable ()
11
12 newtype Unit
13 = Unit Text
14 deriving (Data, Eq, IsString, Ord, Show, Typeable)
15
16 -- NOTE: maybe consider using text-show package
17 text :: Unit -> Text
18 text (Unit t) = t
19
20 nil :: Unit
21 nil = Unit ""
22
23 length :: Unit -> Int
24 length = Text.length . text