composite-aeson-throw (empty) → 0.1.0.0
raw patch · 5 files changed
+91/−0 lines, 5 filesdep +aesondep +aeson-better-errorsdep +base
Dependencies added: aeson, aeson-better-errors, base, composite-aeson, exceptions
Files
- ChangeLog.md +5/−0
- LICENSE +19/−0
- README.md +3/−0
- composite-aeson-throw.cabal +35/−0
- src/Composite/Aeson/Throw.hs +29/−0
+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Changelog for composite-aeson-throw++# v0.1.0.0++* Add `MonadThrow` version of ABE's `parseValue`.
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2020 Daniel Firth++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
+ README.md view
@@ -0,0 +1,3 @@+# composite-aeson-throw++`MonadThrow` for composite-aeson parsing.
+ composite-aeson-throw.cabal view
@@ -0,0 +1,35 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.34.2.+--+-- see: https://github.com/sol/hpack++name: composite-aeson-throw+version: 0.1.0.0+synopsis: MonadThrow behaviour for composite-aeson.+description: MonadThrow behaviour for composite-aeson.+category: Text+author: Daniel Firth+maintainer: dan.firth@homotopic.tech+copyright: 2020 Daniel Firth+license: MIT+license-file: LICENSE+build-type: Simple+extra-source-files:+ README.md+ ChangeLog.md++library+ exposed-modules:+ Composite.Aeson.Throw+ other-modules:+ Paths_composite_aeson_throw+ hs-source-dirs:+ src+ build-depends:+ aeson+ , aeson-better-errors+ , base >=4.7 && <5+ , composite-aeson+ , exceptions+ default-language: Haskell2010
+ src/Composite/Aeson/Throw.hs view
@@ -0,0 +1,29 @@+{- |+ Module : Composite.Aeson.Throw+ License : MIT+ Stability : experimental++MonadThrow behaviour for composite-aeson.+-}+module Composite.Aeson.Throw (+ CompositeAesonParseException+, parseValue'+) where++import Composite.Aeson+import Control.Monad.Catch+import Data.Aeson+import Data.Aeson.BetterErrors+import Data.Typeable++-- | Simple exception type for composite-aeson.+newtype CompositeAesonParseException a = CompositeAesonParseException a+ deriving (Eq, Show, Ord)++instance (Typeable a, Show a) => Exception (CompositeAesonParseException a)++-- | Parse a value according to the provided `JsonFormat` and throw to `MonadThrow` on exception.+parseValue' :: (Typeable e, Show e, MonadThrow m) => JsonFormat e x -> Value -> m x+parseValue' f v = do+ let a = parseValue (fromJsonWithFormat f) v+ either (throwM . CompositeAesonParseException) return a