Wed Feb 23 16:08:53 2022 UTC ()
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/


(pho)
diff -r0 -r1.1 pkgsrc/converters/hs-aeson-better-errors/DESCR
diff -r0 -r1.1 pkgsrc/converters/hs-aeson-better-errors/Makefile
diff -r0 -r1.1 pkgsrc/converters/hs-aeson-better-errors/PLIST
diff -r0 -r1.1 pkgsrc/converters/hs-aeson-better-errors/buildlink3.mk
diff -r0 -r1.1 pkgsrc/converters/hs-aeson-better-errors/distinfo
diff -r0 -r1.1 pkgsrc/converters/hs-aeson-better-errors/patches/patch-src_Data_Aeson_BetterErrors_Internal.hs

File Added: pkgsrc/converters/hs-aeson-better-errors/DESCR
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/

File Added: pkgsrc/converters/hs-aeson-better-errors/Makefile
# $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"

File Added: pkgsrc/converters/hs-aeson-better-errors/PLIST
@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

File Added: pkgsrc/converters/hs-aeson-better-errors/buildlink3.mk
# $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

File Added: pkgsrc/converters/hs-aeson-better-errors/distinfo
$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

File Added: pkgsrc/converters/hs-aeson-better-errors/patches/patch-src_Data_Aeson_BetterErrors_Internal.hs
$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