Achieve 100% haddock coverage; do not inline CAFs that should be shared.
[haskell-cryptsy-api.git] / src / Cryptsy / API / Public / Types / Num.hs
blobe6673747d26b3da56a4bc497b833c1562df70ea1
1 {-# LANGUAGE EmptyDataDecls, GeneralizedNewtypeDeriving #-}
2 -- |Default numeric type for prices, quanities, and total returned from the
3 -- API.
4 module Cryptsy.API.Public.Types.Num where
6 -- aeson
7 import Data.Aeson (FromJSON(..))
9 -- base
10 import Data.Fixed (HasResolution(..), Fixed)
11 import Numeric (readFloat)
13 -- this package
14 import Cryptsy.API.Public.Types.Internal
16 -- |Custom resolution for 'Fixed'; 1e8.
17 data E8
19 instance HasResolution E8 where
20 resolution = const 100000000
22 -- |Native number type for the API, newtype for custom FromJSON instance, which
23 -- only accepts JSON strings.
24 newtype CryptsyNum = CryptsyNum { toFixed :: Fixed E8 } deriving
25 (Eq, Ord, Show, Read, Num, Real, Fractional, Enum, RealFrac)
27 instance FromJSON CryptsyNum where
28 parseJSON = readsToParser "CrypstyNum" readFloat