{-# LANGUAGE DeriveDataTypeable #-} module Hcompta.Model.Amount.Style where import Data.Data import Data.Word (Word8) import Data.Typeable () -- * The 'Style' type data Style = Style { decimal_point :: Maybe Char , format :: Maybe Format , precision :: Word8 , unit_side :: Maybe Side , unit_spaced :: Maybe Bool } deriving (Data, Eq, Ord, Read, Show, Typeable) data Side = Side_Left | Side_Right deriving (Data, Eq, Ord, Read, Show, Typeable) data Format = Format Char [Int] deriving (Data, Eq, Ord, Read, Show, Typeable) -- * Constructors null :: Style null = Style { decimal_point = Nothing , format = Nothing , precision = 0 , unit_side = Nothing , unit_spaced = Nothing } -- * Operators union :: Style -> Style -> Style union style@Style { decimal_point=decimal_point_ , format=format_ , precision=precision_ , unit_side=side , unit_spaced=spaced } style'@Style { decimal_point=decimal_point' , format=format_' , precision=precision' , unit_side=side' , unit_spaced=spaced' } = if style == style' then style' else Style { decimal_point=maybe decimal_point' (const decimal_point_) decimal_point_ , format=maybe format_' (const format_) format_ , precision=max precision_ precision' , unit_side=maybe side' (const side) side , unit_spaced=maybe spaced' (const spaced) spaced }