1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE FlexibleInstances #-}
4 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
5 {-# LANGUAGE OverloadedStrings #-}
6 {-# LANGUAGE StandaloneDeriving #-}
7 {-# LANGUAGE TypeFamilies #-}
8 {-# OPTIONS_GHC -fno-warn-orphans #-}
9 module Hcompta.Format.Ledger.Unit where
11 import Control.DeepSeq
13 import Data.Eq (Eq(..))
14 import Data.Ord (Ord(..))
15 import Data.String (IsString)
16 import Data.Text (Text)
17 import qualified Data.Text as Text
18 import Data.Typeable ()
19 import Prelude ((.), Int)
20 import Text.Show (Show(..))
22 import qualified Hcompta.Unit as Unit
26 newtype Unit = Unit Text
27 deriving (Data, Eq, IsString, Ord, Show, Typeable)
28 instance Unit.Unit Unit where
30 unit_text (Unit t) = t
31 instance NFData Unit where
34 unit_length :: Unit -> Int
35 unit_length = Text.length . Unit.unit_text
39 -- | 'Unit.unit_empty'.
41 scalar = Unit.unit_empty
43 -- | <https://en.wikipedia.org/wiki/Swiss_franc Swiss franc> unit of currency.
47 -- | <https://en.wikipedia.org/wiki/Yuan Yuan> unit of currency.
51 -- | <https://en.wikipedia.org/wiki/Euro Euro> unit of currency.
55 -- | <https://en.wikipedia.org/wiki/Pound_sterling Pound sterling> unit of currency.
59 -- | <https://en.wikipedia.org/wiki/Indian_rupee Indian rupee> unit of currency.
63 -- | <https://en.wikipedia.org/wiki/Japanese_yen Japanese yen> unit of currency.
67 -- | <https://en.wikipedia.org/wiki/Russian_ruble Russian ruble> unit of currency.
69 -- NOTE: Ꝑ (U+A750) is used as a replacement latin letter,
70 -- because GHC currently chokes on ₽ (U+20BD),
71 -- which is the recently (2014/02) assigned Unicode code-point
76 -- | <https://en.wikipedia.org/wiki/United_States_dollar United States dollar> unit of currency.