fay 0.19 → 0.19.0.1
raw patch · 4 files changed
+27/−3 lines, 4 filesdep +scientificdep ~aeson
Dependencies added: scientific
Dependency ranges changed: aeson
Files
- CHANGELOG.md +5/−0
- fay.cabal +3/−2
- src/Fay/Compiler/Print.hs +1/−1
- src/Fay/Convert.hs +18/−0
CHANGELOG.md view
@@ -3,6 +3,11 @@ See full history at: <https://github.com/faylang/fay/commits> +#### 0.19.0.1 (2014-01-15)++Dependency bumps:+* Allow `aeson 0.7.*`+ ## 0.19 (2014-01-14) * Made import Prelude is implicit, but note that RebindableSyntax implies NoImplicitPrelude.
fay.cabal view
@@ -1,5 +1,5 @@ name: fay-version: 0.19+version: 0.19.0.1 synopsis: A compiler for Fay, a Haskell subset that compiles to JavaScript. description: Fay is a proper subset of Haskell which is type-checked with GHC, and compiled to JavaScript. It is lazy, pure, has a Fay monad,@@ -107,7 +107,7 @@ ghc-options: -O2 -Wall -fno-warn-name-shadowing build-depends: base >= 4 && < 5 , Cabal < 1.19- , aeson < 0.7+ , aeson < 0.8 , attoparsec < 0.12 , bytestring < 0.11 , containers < 0.6@@ -133,6 +133,7 @@ , utf8-string < 0.4 , vector < 0.11 , sourcemap < 0.2+ , scientific < 0.3 executable fay hs-source-dirs: src/main
src/Fay/Compiler/Print.hs view
@@ -46,7 +46,7 @@ -- JS-format literals. Could use the Text.JSON library. instance Printable JsLit where printJS typ = write $- let u8 = UTF8.toString . encode . UTF8.fromString+ let u8 = UTF8.toString . encode in case typ of (JsChar char) -> u8 [char] (JsStr str) -> u8 str
src/Fay/Convert.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards #-}@@ -30,6 +31,9 @@ import Numeric import Safe import qualified Text.Show.Pretty as Show+#if MIN_VERSION_aeson(0,7,0)+import Data.Scientific+#endif -------------------------------------------------------------------------------- -- The conversion functions.@@ -69,8 +73,14 @@ int = convertInt value -- Number converters++#if MIN_VERSION_aeson(0,7,0)+ convertDouble = fmap (Number . fromFloatDigits) . pDouble+ convertInt = fmap (Number . fromInteger) . pInt+#else convertDouble = fmap (Number . D) . pDouble convertInt = fmap (Number . I) . pInt+#endif -- Number parsers pDouble :: Show.Value -> Maybe Double@@ -193,9 +203,17 @@ -- | Parse a number. parseNumber :: Value -> Maybe Number+#if MIN_VERSION_aeson(0,7,0) parseNumber value = case value of+ Number n+ | base10Exponent n >= 0 -> return . I . round $ n+ | otherwise -> return . D . fromRational . toRational $ n+ _ -> mzero+#else+parseNumber value = case value of Number n -> return n _ -> mzero+#endif -- | Parse a bool. parseBool :: Value -> Maybe Bool