]> Git — Sourcephile - comptalang.git/blob - lib/Hcompta/Model/Amount/Unit.hs
Modif : CLI.Lang : utilise la classe ToDoc pour gérer les traductions.
[comptalang.git] / lib / Hcompta / Model / Amount / Unit.hs
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
3 {-# LANGUAGE OverloadedStrings #-}
4 module Hcompta.Model.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 import qualified Hcompta.Model.Filter as Model.Filter
13
14 newtype Unit
15 = Unit Text
16 deriving (Data, Eq, IsString, Ord, Show, Typeable)
17
18 instance Model.Filter.Unit Unit where
19 unit_text = text
20
21 -- NOTE: maybe consider using text-show package
22 text :: Unit -> Text
23 text (Unit t) = t
24
25 nil :: Unit
26 nil = Unit ""
27
28 length :: Unit -> Int
29 length = Text.length . text