1 {-# LANGUAGE DeriveDataTypeable #-}
2 module Hcompta.Amount.Style where
6 import Data.Char (Char)
8 import Data.Eq (Eq(..))
9 import Data.Maybe (Maybe(..), maybe)
10 import Data.Ord (Ord(..))
11 import Data.Typeable ()
12 import Data.Word (Word8)
13 import Prelude (Int, Show(..), const, seq)
19 { fractioning :: Maybe Fractioning
20 , grouping_integral :: Maybe Grouping
21 , grouping_fractional :: Maybe Grouping
22 , precision :: Precision
23 -- TODO: , sign_plus :: Maybe Bool
24 , unit_side :: Maybe Side
25 , unit_spaced :: Maybe Spacing
26 } deriving (Data, Eq, Ord, Show, Typeable)
27 instance NFData Style where
28 rnf (Style f gi gf p ui up) =
41 deriving (Data, Eq, Ord, Show, Typeable)
42 instance NFData Grouping where
43 rnf (Grouping s d) = rnf s `seq` rnf d
54 deriving (Data, Eq, Ord, Show, Typeable)
55 instance NFData Side where
64 { fractioning = Nothing
65 , grouping_integral = Nothing
66 , grouping_fractional = Nothing
69 , unit_spaced = Nothing
74 union :: Style -> Style -> Style
77 { fractioning=fractioning_
78 , grouping_integral=grouping_integral_
79 , grouping_fractional=grouping_fractional_
80 , precision=precision_
85 { fractioning=fractioning'
86 , grouping_integral=grouping_integral_'
87 , grouping_fractional=grouping_fractional_'
88 , precision=precision'
96 { fractioning=maybe fractioning' (const fractioning_) fractioning_
97 , grouping_integral=maybe grouping_integral_' (const grouping_integral_) grouping_integral_
98 , grouping_fractional=maybe grouping_fractional_' (const grouping_fractional_) grouping_fractional_
99 , precision=max precision_ precision'
100 , unit_side=maybe side' (const side) side
101 , unit_spaced=maybe spaced' (const spaced) spaced