{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} module Hcompta.Amount.Unit where import Control.DeepSeq import Data.Data import Data.String (IsString) import qualified Data.Text as Text import Data.Text (Text) import Data.Typeable () newtype Unit = Unit Text deriving (Data, Eq, IsString, Ord, Show, Typeable) instance NFData Unit where rnf (Unit t) = rnf t -- 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