1 {-# LANGUAGE EmptyDataDecls, GeneralizedNewtypeDeriving #-}
2 -- |Default numeric type for prices, quanities, and total returned from the
4 module Cryptsy
.API
.Public
.Types
.Num
where
7 import Data
.Aeson
(FromJSON
(..))
10 import Data
.Fixed
(HasResolution
(..), Fixed
)
11 import Numeric
(readFloat)
14 import Cryptsy
.API
.Public
.Types
.Internal
16 -- |Custom resolution for 'Fixed'; 1e8.
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