summaryrefslogtreecommitdiff
path: root/converters
diff options
context:
space:
mode:
authorpho <pho@pkgsrc.org>2022-02-23 16:08:53 +0000
committerpho <pho@pkgsrc.org>2022-02-23 16:08:53 +0000
commit4ddc1ec27a1252e10810e54a1ce0aede3317bae6 (patch)
tree0f11b2ce41a87865d46a8ce72f2cd864b8d6cac1 /converters
parent2e69466c084a4a93d36f9af050e1f575d45c6c27 (diff)
downloadpkgsrc-4ddc1ec27a1252e10810e54a1ce0aede3317bae6.tar.gz
converters/hs-aeson-better-errors: import hs-aeson-better-errors-0.9.1.0
A small package which gives you the tools to build parsers to decode JSON values, and gives good error messages when parsing fails. See also http://harry.garrood.me/blog/aeson-better-errors/
Diffstat (limited to 'converters')
-rw-r--r--converters/hs-aeson-better-errors/DESCR3
-rw-r--r--converters/hs-aeson-better-errors/Makefile18
-rw-r--r--converters/hs-aeson-better-errors/PLIST26
-rw-r--r--converters/hs-aeson-better-errors/buildlink3.mk21
-rw-r--r--converters/hs-aeson-better-errors/distinfo6
-rw-r--r--converters/hs-aeson-better-errors/patches/patch-src_Data_Aeson_BetterErrors_Internal.hs91
6 files changed, 165 insertions, 0 deletions
diff --git a/converters/hs-aeson-better-errors/DESCR b/converters/hs-aeson-better-errors/DESCR
new file mode 100644
index 00000000000..5b8bec65d00
--- /dev/null
+++ b/converters/hs-aeson-better-errors/DESCR
@@ -0,0 +1,3 @@
+A small package which gives you the tools to build parsers to decode JSON
+values, and gives good error messages when parsing fails. See also
+http://harry.garrood.me/blog/aeson-better-errors/
diff --git a/converters/hs-aeson-better-errors/Makefile b/converters/hs-aeson-better-errors/Makefile
new file mode 100644
index 00000000000..c6d9e0908b2
--- /dev/null
+++ b/converters/hs-aeson-better-errors/Makefile
@@ -0,0 +1,18 @@
+# $NetBSD: Makefile,v 1.1 2022/02/23 16:08:53 pho Exp $
+
+DISTNAME= aeson-better-errors-0.9.1.0
+CATEGORIES= converters
+
+MAINTAINER= pkgsrc-users@NetBSD.org
+COMMENT= Better error messages when decoding JSON values
+LICENSE= mit
+
+.include "../../converters/hs-aeson/buildlink3.mk"
+.include "../../devel/hs-dlist/buildlink3.mk"
+.include "../../math/hs-scientific/buildlink3.mk"
+.include "../../devel/hs-transformers-compat/buildlink3.mk"
+.include "../../devel/hs-unordered-containers/buildlink3.mk"
+.include "../../devel/hs-vector/buildlink3.mk"
+.include "../../devel/hs-void/buildlink3.mk"
+.include "../../mk/haskell.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/converters/hs-aeson-better-errors/PLIST b/converters/hs-aeson-better-errors/PLIST
new file mode 100644
index 00000000000..50daafa01fa
--- /dev/null
+++ b/converters/hs-aeson-better-errors/PLIST
@@ -0,0 +1,26 @@
+@comment $NetBSD: PLIST,v 1.1 2022/02/23 16:08:53 pho Exp $
+lib/aeson-better-errors-${PKGVERSION}/${HS_VERSION}/package-description
+lib/aeson-better-errors-${PKGVERSION}/${HS_VERSION}/package-id
+lib/${HS_PLATFORM}/${HS_PKGID}/Data/Aeson/BetterErrors.dyn_hi
+lib/${HS_PLATFORM}/${HS_PKGID}/Data/Aeson/BetterErrors.hi
+lib/${HS_PLATFORM}/${HS_PKGID}/Data/Aeson/BetterErrors.p_hi
+lib/${HS_PLATFORM}/${HS_PKGID}/Data/Aeson/BetterErrors/Internal.dyn_hi
+lib/${HS_PLATFORM}/${HS_PKGID}/Data/Aeson/BetterErrors/Internal.hi
+lib/${HS_PLATFORM}/${HS_PKGID}/Data/Aeson/BetterErrors/Internal.p_hi
+lib/${HS_PLATFORM}/${HS_PKGID}/Data/Aeson/BetterErrors/Utils.dyn_hi
+lib/${HS_PLATFORM}/${HS_PKGID}/Data/Aeson/BetterErrors/Utils.hi
+lib/${HS_PLATFORM}/${HS_PKGID}/Data/Aeson/BetterErrors/Utils.p_hi
+lib/${HS_PLATFORM}/${HS_PKGID}/libHS${HS_PKGID}.a
+lib/${HS_PLATFORM}/${HS_PKGID}/libHS${HS_PKGID}_p.a
+lib/${HS_PLATFORM}/libHS${HS_PKGID}-${HS_VER}.so
+share/doc/${HS_PLATFORM}/aeson-better-errors-${PKGVERSION}/LICENSE
+share/doc/${HS_PLATFORM}/aeson-better-errors-${PKGVERSION}/html/Data-Aeson-BetterErrors-Internal.html
+share/doc/${HS_PLATFORM}/aeson-better-errors-${PKGVERSION}/html/Data-Aeson-BetterErrors.html
+share/doc/${HS_PLATFORM}/aeson-better-errors-${PKGVERSION}/html/aeson-better-errors.haddock
+share/doc/${HS_PLATFORM}/aeson-better-errors-${PKGVERSION}/html/doc-index.html
+share/doc/${HS_PLATFORM}/aeson-better-errors-${PKGVERSION}/html/haddock-bundle.min.js
+share/doc/${HS_PLATFORM}/aeson-better-errors-${PKGVERSION}/html/index.html
+share/doc/${HS_PLATFORM}/aeson-better-errors-${PKGVERSION}/html/linuwial.css
+share/doc/${HS_PLATFORM}/aeson-better-errors-${PKGVERSION}/html/meta.json
+share/doc/${HS_PLATFORM}/aeson-better-errors-${PKGVERSION}/html/quick-jump.css
+share/doc/${HS_PLATFORM}/aeson-better-errors-${PKGVERSION}/html/synopsis.png
diff --git a/converters/hs-aeson-better-errors/buildlink3.mk b/converters/hs-aeson-better-errors/buildlink3.mk
new file mode 100644
index 00000000000..642e267de29
--- /dev/null
+++ b/converters/hs-aeson-better-errors/buildlink3.mk
@@ -0,0 +1,21 @@
+# $NetBSD: buildlink3.mk,v 1.1 2022/02/23 16:08:53 pho Exp $
+
+BUILDLINK_TREE+= hs-aeson-better-errors
+
+.if !defined(HS_AESON_BETTER_ERRORS_BUILDLINK3_MK)
+HS_AESON_BETTER_ERRORS_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.hs-aeson-better-errors+= hs-aeson-better-errors>=0.9.1
+BUILDLINK_ABI_DEPENDS.hs-aeson-better-errors+= hs-aeson-better-errors>=0.9.1.0
+BUILDLINK_PKGSRCDIR.hs-aeson-better-errors?= ../../converters/hs-aeson-better-errors
+
+.include "../../converters/hs-aeson/buildlink3.mk"
+.include "../../devel/hs-dlist/buildlink3.mk"
+.include "../../math/hs-scientific/buildlink3.mk"
+.include "../../devel/hs-transformers-compat/buildlink3.mk"
+.include "../../devel/hs-unordered-containers/buildlink3.mk"
+.include "../../devel/hs-vector/buildlink3.mk"
+.include "../../devel/hs-void/buildlink3.mk"
+.endif # HS_AESON_BETTER_ERRORS_BUILDLINK3_MK
+
+BUILDLINK_TREE+= -hs-aeson-better-errors
diff --git a/converters/hs-aeson-better-errors/distinfo b/converters/hs-aeson-better-errors/distinfo
new file mode 100644
index 00000000000..c3b326b9d24
--- /dev/null
+++ b/converters/hs-aeson-better-errors/distinfo
@@ -0,0 +1,6 @@
+$NetBSD: distinfo,v 1.1 2022/02/23 16:08:53 pho Exp $
+
+BLAKE2s (aeson-better-errors-0.9.1.0.tar.gz) = 624b0cd5a9158b53c8f584b744b1a6f8b879d08048579f639971ec2d1db66001
+SHA512 (aeson-better-errors-0.9.1.0.tar.gz) = 3ff1a0f85f39df01f8cfa0fe4682a97f69a324c8b344f7bb005a84e4adb4c0dabe463e3a029a74012b101413532d3f5d3a4be92671d14b5387fb61ca8e1540c6
+Size (aeson-better-errors-0.9.1.0.tar.gz) = 8401 bytes
+SHA1 (patch-src_Data_Aeson_BetterErrors_Internal.hs) = 544645a1da856bae7c5a62e2b8323ba13b814df9
diff --git a/converters/hs-aeson-better-errors/patches/patch-src_Data_Aeson_BetterErrors_Internal.hs b/converters/hs-aeson-better-errors/patches/patch-src_Data_Aeson_BetterErrors_Internal.hs
new file mode 100644
index 00000000000..c61fb4ed44f
--- /dev/null
+++ b/converters/hs-aeson-better-errors/patches/patch-src_Data_Aeson_BetterErrors_Internal.hs
@@ -0,0 +1,91 @@
+$NetBSD: patch-src_Data_Aeson_BetterErrors_Internal.hs,v 1.1 2022/02/23 16:08:53 pho Exp $
+
+Fix build with aeson-2.0
+
+--- src/Data/Aeson/BetterErrors/Internal.hs.orig 2022-02-20 12:31:25.835056290 +0000
++++ src/Data/Aeson/BetterErrors/Internal.hs
+@@ -33,7 +33,8 @@ import Data.Vector ((!?))
+ import qualified Data.Vector as V
+ import Data.Scientific (Scientific)
+ import qualified Data.Scientific as S
+-import qualified Data.HashMap.Strict as HashMap
++import Data.Aeson.Key (Key)
++import qualified Data.Aeson.KeyMap as KeyMap
+
+ import Data.Aeson.BetterErrors.Utils
+
+@@ -178,7 +179,7 @@ setValue v r = r { rdrValue = v }
+ -- Internally, a list of these is maintained as the parser traverses the JSON
+ -- data. This list is included in the error if one occurs.
+ data PathPiece
+- = ObjectKey Text
++ = ObjectKey Key
+ | ArrayIndex Int
+ deriving (Show, Eq, Ord)
+
+@@ -201,7 +202,7 @@ type ParseError' = ParseError Void
+ -- but a value of the required type could not be constructed from it, for some
+ -- reason.
+ data ErrorSpecifics err
+- = KeyMissing Text
++ = KeyMissing Key
+ | OutOfBounds Int
+ | WrongType JSONType A.Value -- ^ Expected type, actual value
+ | ExpectedIntegral Double
+@@ -369,25 +370,25 @@ perhaps p = do
+ _ -> Just <$> p
+
+ -- | Take the value corresponding to a given key in the current object.
+-key :: (Functor m, Monad m) => Text -> ParseT err m a -> ParseT err m a
++key :: (Functor m, Monad m) => Key -> ParseT err m a -> ParseT err m a
+ key k p = key' (badSchema (KeyMissing k)) k p
+
+ -- | Take the value corresponding to a given key in the current object, or
+ -- if no property exists with that key, use the supplied default.
+-keyOrDefault :: (Functor m, Monad m) => Text -> a -> ParseT err m a -> ParseT err m a
++keyOrDefault :: (Functor m, Monad m) => Key -> a -> ParseT err m a -> ParseT err m a
+ keyOrDefault k def p = key' (pure def) k p
+
+ -- | Take the value corresponding to a given key in the current object, or
+ -- if no property exists with that key, return Nothing .
+-keyMay :: (Functor m, Monad m) => Text -> ParseT err m a -> ParseT err m (Maybe a)
++keyMay :: (Functor m, Monad m) => Key -> ParseT err m a -> ParseT err m (Maybe a)
+ keyMay k p = keyOrDefault k Nothing (Just <$> p)
+
+-key' :: (Functor m, Monad m) => ParseT err m a -> Text -> ParseT err m a -> ParseT err m a
++key' :: (Functor m, Monad m) => ParseT err m a -> Key -> ParseT err m a -> ParseT err m a
+ key' onMissing k p = do
+ v <- asks rdrValue
+ case v of
+ A.Object obj ->
+- case HashMap.lookup k obj of
++ case KeyMap.lookup k obj of
+ Just v' ->
+ local (appendPath (ObjectKey k) . setValue v') p
+ Nothing ->
+@@ -433,21 +434,21 @@ eachInArray p = do
+
+ -- | Parse each property in an object with the given parser, given the key as
+ -- an argument, and collect the results.
+-forEachInObject :: (Functor m, Monad m) => (Text -> ParseT err m a) -> ParseT err m [a]
++forEachInObject :: (Functor m, Monad m) => (Key -> ParseT err m a) -> ParseT err m [a]
+ forEachInObject p = do
+- xs <- HashMap.toList <$> asObject
++ xs <- KeyMap.toList <$> asObject
+ forM xs $ \(k, x) ->
+ local (appendPath (ObjectKey k) . setValue x) (p k)
+
+ -- | Attempt to parse each property value in the object with the given parser,
+ -- and collect the results.
+-eachInObject :: (Functor m, Monad m) => ParseT err m a -> ParseT err m [(Text, a)]
++eachInObject :: (Functor m, Monad m) => ParseT err m a -> ParseT err m [(Key, a)]
+ eachInObject = eachInObjectWithKey Right
+
+ -- | Attempt to parse each property in the object: parse the key with the
+ -- given validation function, parse the value with the given parser, and
+ -- collect the results.
+-eachInObjectWithKey :: (Functor m, Monad m) => (Text -> Either err k) -> ParseT err m a -> ParseT err m [(k, a)]
++eachInObjectWithKey :: (Functor m, Monad m) => (Key -> Either err k) -> ParseT err m a -> ParseT err m [(k, a)]
+ eachInObjectWithKey parseKey parseVal = forEachInObject $ \k ->
+ (,) <$> liftEither (parseKey k) <*> parseVal
+