Suppression : Lib.Foldable : Composition déjà dans Data.Functor.Compose.
[comptalang.git] / lib / Hcompta / Model / Amount / Unit.hs
index 73ddca15b564e0f696551ccc5160b22d97730e26..a5ca65ce11d7a1a6ace5e4710d9b4942a44f58f7 100644 (file)
@@ -1,4 +1,29 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE OverloadedStrings #-}
 module Hcompta.Model.Amount.Unit where
 
-type Unit
- = String
+import           Data.Data
+import           Data.String (IsString)
+import qualified Data.Text as Text
+import           Data.Text (Text)
+import           Data.Typeable ()
+
+import qualified Hcompta.Model.Filter as Model.Filter
+
+newtype Unit
+ = Unit Text
+ deriving (Data, Eq, IsString, Ord, Show, Typeable)
+
+instance Model.Filter.Unit Unit where
+       unit_text = text
+
+-- NOTE: maybe consider using text-show package
+text :: Unit -> Text
+text (Unit t) = t
+
+nil :: Unit
+nil = Unit ""
+
+length :: Unit -> Int
+length = Text.length . text