packages feed

purescript-iso 0.0.1.6 → 0.0.1.7

raw patch · 2 files changed

+22/−7 lines, 2 files

Files

purescript-iso.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 8e8d24cfc61174c33dac1b32698941164308ff3d77270a9ecd23f08eba1f3e59+-- hash: 2c400182fe75e3c87f3c64cd53689d580652b27da9265d5a5b63c3e11e0778a7  name:           purescript-iso-version:        0.0.1.6+version:        0.0.1.7 synopsis:       Isomorphic trivial data type definitions over JSON description:    Please see the README on GitHub at <https://github.com/githubuser/purescript-iso#readme> category:       Web
src/Data/Aeson/JSONInteger.hs view
@@ -3,13 +3,13 @@   , GeneralizedNewtypeDeriving   #-} -module Data.Aeson.JSONInteger where+module Data.Aeson.JSONInteger (JSONInteger, jsonInteger, getJSONInteger) where  import Data.Aeson (ToJSON (..), FromJSON (..), Value (String)) import Data.Aeson.Types (typeMismatch) import Data.Aeson.Attoparsec (attoAeson) import Data.Attoparsec.Text (decimal, signed)-import Data.Scientific (Scientific, coefficient, base10Exponent)+import Data.Scientific (Scientific, coefficient, base10Exponent, scientific) import qualified Data.Text as T import Text.Read (readMaybe) import GHC.Generics (Generic)@@ -18,9 +18,24 @@ import System.IO.Unsafe (unsafePerformIO)  -newtype JSONInteger = JSONInteger-  { getJSONInteger :: Scientific-  } deriving (Eq, Ord{-, Enum-}, Show, Read, Generic, Num, Real{-, Integral-})+newtype JSONInteger = JSONInteger Scientific+  deriving (Eq, Ord, Show, Read, Generic, Num, Real)++instance Enum JSONInteger where+  toEnum = jsonInteger . fromIntegral+  fromEnum = fromIntegral . getJSONInteger++instance Integral JSONInteger where+  toInteger = getJSONInteger+  quotRem x y =+    let (a,b) = quotRem (toInteger x) (toInteger y)+    in  (jsonInteger a, jsonInteger b)++jsonInteger :: Integer -> JSONInteger+jsonInteger i = JSONInteger (scientific i 0)++getJSONInteger :: JSONInteger -> Integer+getJSONInteger (JSONInteger x) = coefficient x * (10 ^ base10Exponent x)  instance ToJSON JSONInteger where   toJSON (JSONInteger x) = toJSON $