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