packages feed

json-to-haskell 0.1.1.0 → 0.1.1.1

raw patch · 6 files changed

+20/−16 lines, 6 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ JsonToHaskell.Internal.Options: instance GHC.Classes.Eq JsonToHaskell.Internal.Options.Options
+ JsonToHaskell.Internal.Options: instance GHC.Classes.Ord JsonToHaskell.Internal.Options.ListType
+ JsonToHaskell.Internal.Options: instance GHC.Classes.Ord JsonToHaskell.Internal.Options.MapType
+ JsonToHaskell.Internal.Options: instance GHC.Classes.Ord JsonToHaskell.Internal.Options.NumberType
+ JsonToHaskell.Internal.Options: instance GHC.Classes.Ord JsonToHaskell.Internal.Options.Options
+ JsonToHaskell.Internal.Options: instance GHC.Classes.Ord JsonToHaskell.Internal.Options.TextType
+ JsonToHaskell.Internal.Options: instance GHC.Show.Show JsonToHaskell.Internal.Options.Options

Files

+ CHANGElOG.md view
@@ -0,0 +1,6 @@+# Changelog for json-to-haskell++## 0.1.1.1+- Only look at first element of lists when determining type++## Unreleased changes
− ChangeLog.md
@@ -1,3 +0,0 @@-# Changelog for json-to-haskell--## Unreleased changes
json-to-haskell.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 65d00b5d14a553066c2b8ecf023d27cd097b384b29843540e4273883dff5d436+-- hash: 2c356673661763f7b6e9541e054c697801872e029c40f11d3ca0f795c52037cf  name:           json-to-haskell-version:        0.1.1.0+version:        0.1.1.1 description:    Please see the README on GitHub at <https://github.com/ChrisPenner/json-to-haskell#readme> homepage:       https://github.com/ChrisPenner/json-to-haskell#readme bug-reports:    https://github.com/ChrisPenner/json-to-haskell/issues@@ -19,7 +19,7 @@ build-type:     Simple extra-source-files:     README.md-    ChangeLog.md+    CHANGElOG.md  source-repository head   type: git
src/JsonToHaskell/Internal/Options.hs view
@@ -15,7 +15,7 @@   | UseDoubles     -- | Use 'Scientific' for all numbers   | UseScientific-  deriving (Show, Eq)+  deriving (Show, Eq, Ord)  -- | Choose which type to use for strings data TextType =@@ -25,7 +25,7 @@   | UseText     -- | Use 'ByteString' for strings   | UseByteString-  deriving (Show, Eq)+  deriving (Show, Eq, Ord)  -- | Choose which type to use for key-value maps data MapType =@@ -33,7 +33,7 @@     UseMap     -- | Use Data.HashMap   | UseHashMap-  deriving (Show, Eq)+  deriving (Show, Eq, Ord)  -- | Choose which type to use for arrays data ListType =@@ -41,7 +41,7 @@     UseList     -- | Use vectors   | UseVector-  deriving (Show, Eq)+  deriving (Show, Eq, Ord)  -- | Options for module generation data Options = Options@@ -54,7 +54,7 @@   , _includeInstances :: Bool   , _strictData :: Bool   , _prefixRecordFields :: Bool-  }+  } deriving (Show, Eq, Ord)   makeLenses ''Options
src/JsonToHaskell/Internal/Parser.hs view
@@ -75,10 +75,9 @@             nameRecord m'             pure $ SRecord m'         ArrayF itemsM -> do-            items <- sequenceA itemsM-            pure $ case (items V.!? 0) of-                Just s  -> SArray s-                Nothing -> SArray SValue+            case (itemsM V.!? 0) of+                Just s  -> SArray <$> s+                Nothing -> pure $ SArray SValue         StringF _     -> pure SString         NumberF n     -> pure . SNumber             $ if (ceiling n == (floor n :: Int))
src/JsonToHaskell/Internal/Printer.hs view
@@ -19,7 +19,7 @@ import qualified Data.Map as M import qualified Data.Text as T import Text.Casing (toCamel, fromAny)-import Data.Char (isAlpha, isAlphaNum, toUpper)+import Data.Char (isAlpha, isAlphaNum) import Lens.Micro.Platform (view, (+~), (<&>))  @@ -181,6 +181,7 @@     includeScientific <- view (options . numberType) <&> (== UseScientific)     includeVector <- view (options . listType) <&> (== UseVector)     includeText <- view (options . textType) <&> (== UseText)+    includeByteString <- view (options . textType) <&> (== UseByteString)     when incHeader $ do         tell . T.unlines $             [ "{-# LANGUAGE DuplicateRecordFields #-}"@@ -194,6 +195,7 @@         when includeVector . line . tell $ "import Data.Vector (Vector)"         when includeScientific . line . tell $ "import Data.Scientific (Scientific)"         when includeText . line . tell $ "import Data.Text (Text)"+        when includeByteString . line . tell $ "import Data.ByteString (ByteString)"         newline     void . flip M.traverseWithKey m $ \k v -> do         writeRecord k v