hw-aeson (empty) → 0.1.0.0
raw patch · 7 files changed
+136/−0 lines, 7 filesdep +aesondep +basedep +hedgehogsetup-changed
Dependencies added: aeson, base, hedgehog, hspec, hw-aeson, text
Files
- LICENSE +30/−0
- README.md +3/−0
- Setup.hs +2/−0
- hw-aeson.cabal +54/−0
- src/HaskellWorks/Data/Aeson.hs +20/−0
- test/HaskellWorks/Data/AesonSpec.hs +26/−0
- test/Spec.hs +1/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright John Ky (c) 2017-2018++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Author name here nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,3 @@+# hw-aeson++[](https://circleci.com/gh/haskell-works/hw-aeson)
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hw-aeson.cabal view
@@ -0,0 +1,54 @@+-- This file has been generated from package.yaml by hpack version 0.18.1.+--+-- see: https://github.com/sol/hpack++name: hw-aeson+version: 0.1.0.0+synopsis: Convenience functions for Aeson+description: Convenience functions for Aeson+category: Data, JSON+homepage: https://github.com/haskell-works/hw-aeson#readme+bug-reports: https://github.com/haskell-works/hw-aeson/issues+author: John Ky+maintainer: newhoggy@gmail.com+copyright: 2018 John Ky+license: BSD3+license-file: LICENSE+build-type: Simple+cabal-version: >= 1.10++extra-source-files:+ README.md++source-repository head+ type: git+ location: https://github.com/haskell-works/hw-aeson++library+ hs-source-dirs:+ src+ build-depends:+ aeson+ , base >=4.7 && <5+ , text+ exposed-modules:+ HaskellWorks.Data.Aeson+ other-modules:+ Paths_hw_aeson+ default-language: Haskell2010++test-suite hw-aeson-test+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ hs-source-dirs:+ test+ ghc-options: -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ aeson+ , base+ , hspec+ , hedgehog+ , hw-aeson+ other-modules:+ HaskellWorks.Data.AesonSpec+ default-language: Haskell2010
+ src/HaskellWorks/Data/Aeson.hs view
@@ -0,0 +1,20 @@+module HaskellWorks.Data.Aeson+ ( objectWithoutNulls+ , readJson+ ) where++import Data.Aeson+import Data.Aeson.Types+import Data.Text+import Text.Read++objectWithoutNulls :: [Pair] -> Value+objectWithoutNulls = object . Prelude.filter (not . isNull . snd)+ where+ isNull Null = True+ isNull _ = False++readJson :: Read a => String -> String -> Parser a+readJson t s = case readMaybe s of+ Just a -> pure a+ Nothing -> fail $ "Could not parse " <> t
+ test/HaskellWorks/Data/AesonSpec.hs view
@@ -0,0 +1,26 @@+{-# LANGUAGE OverloadedStrings #-}++module HaskellWorks.Data.AesonSpec+ ( spec+ ) where++import Data.Aeson+import Data.Semigroup+import HaskellWorks.Data.Aeson+import Test.Hspec++{-# ANN module ("HLint: ignore Redundant do" :: String) #-}++spec :: Spec+spec = describe "HaskellWorks.Data.Aeson" $ do+ it "objectWithoutNulls should stould strip nulls" $ do+ let actual = objectWithoutNulls+ [ "one" .= (1 :: Int)+ , "two" .= Just (2 :: Int)+ , "three" .= (Nothing :: Maybe Int)+ ]+ let expected = object+ [ "one" .= (1 :: Int)+ , "two" .= (2 :: Int)+ ]+ actual `shouldBe` expected
+ test/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}