mirror of
https://github.com/NorfairKing/autodocodec.git
synced 2024-11-22 04:43:15 +03:00
Add 'HasCodec' instances for 'DList' and 'DNonEmpty' from the 'dlist' package
This commit is contained in:
parent
f1605d38f9
commit
ac36615cb3
@ -42,6 +42,7 @@ extra-source-files:
|
||||
test_resources/json-schema/const.json
|
||||
test_resources/json-schema/day.json
|
||||
test_resources/json-schema/difftime.json
|
||||
test_resources/json-schema/dlist-text.json
|
||||
test_resources/json-schema/dual.json
|
||||
test_resources/json-schema/either-bool-text.json
|
||||
test_resources/json-schema/either-either-bool-scientific-text.json
|
||||
@ -98,6 +99,8 @@ extra-source-files:
|
||||
test_resources/nix/const-type.nix
|
||||
test_resources/nix/day-type.nix
|
||||
test_resources/nix/difftime-type.nix
|
||||
test_resources/nix/dlist-text-type.nix
|
||||
test_resources/nix/dnonempty-text-type.nix
|
||||
test_resources/nix/dual-type.nix
|
||||
test_resources/nix/either-bool-text-type.nix
|
||||
test_resources/nix/either-either-bool-scientific-text-type.nix
|
||||
@ -183,6 +186,8 @@ extra-source-files:
|
||||
test_resources/openapi-schema/declareSchemaRef/void.json
|
||||
test_resources/openapi-schema/declareSchemaRef/war.json
|
||||
test_resources/openapi-schema/difftime.json
|
||||
test_resources/openapi-schema/dlist-text.json
|
||||
test_resources/openapi-schema/dnonempty-text.json
|
||||
test_resources/openapi-schema/dual.json
|
||||
test_resources/openapi-schema/either-bool-text.json
|
||||
test_resources/openapi-schema/either-either-bool-scientific-text.json
|
||||
@ -240,6 +245,8 @@ extra-source-files:
|
||||
test_resources/show-codec/char.txt
|
||||
test_resources/show-codec/const.txt
|
||||
test_resources/show-codec/day.txt
|
||||
test_resources/show-codec/dlist-text.txt
|
||||
test_resources/show-codec/dnonempty-text.txt
|
||||
test_resources/show-codec/dual.txt
|
||||
test_resources/show-codec/either-bool-text.txt
|
||||
test_resources/show-codec/either-either-bool-scientific-text.txt
|
||||
@ -298,6 +305,8 @@ extra-source-files:
|
||||
test_resources/swagger-schema/const.json
|
||||
test_resources/swagger-schema/day.json
|
||||
test_resources/swagger-schema/difftime.json
|
||||
test_resources/swagger-schema/dlist-text.json
|
||||
test_resources/swagger-schema/dnonempty-text.json
|
||||
test_resources/swagger-schema/dual.json
|
||||
test_resources/swagger-schema/either-bool-text.json
|
||||
test_resources/swagger-schema/either-either-bool-scientific-text.json
|
||||
@ -474,9 +483,11 @@ test-suite autodocodec-api-usage-test
|
||||
, base >=4.7 && <5
|
||||
, bytestring
|
||||
, containers
|
||||
, dlist
|
||||
, genvalidity
|
||||
, genvalidity-aeson
|
||||
, genvalidity-containers
|
||||
, genvalidity-dlist
|
||||
, genvalidity-scientific
|
||||
, genvalidity-sydtest
|
||||
, genvalidity-sydtest-aeson
|
||||
|
@ -2,13 +2,14 @@
|
||||
, autodocodec-openapi3, autodocodec-schema
|
||||
, autodocodec-servant-multipart, autodocodec-swagger2
|
||||
, autodocodec-yaml, base, bytestring, containers, criterion
|
||||
, deepseq, genvalidity, genvalidity-aeson, genvalidity-containers
|
||||
, genvalidity-criterion, genvalidity-scientific
|
||||
, genvalidity-sydtest, genvalidity-sydtest-aeson, genvalidity-text
|
||||
, genvalidity-time, lib, openapi3, pretty-show, QuickCheck
|
||||
, safe-coloured-text, scientific, servant-multipart
|
||||
, servant-multipart-api, swagger2, sydtest, sydtest-aeson
|
||||
, sydtest-discover, text, time, unordered-containers, vector, yaml
|
||||
, deepseq, dlist, genvalidity, genvalidity-aeson
|
||||
, genvalidity-containers, genvalidity-criterion, genvalidity-dlist
|
||||
, genvalidity-scientific, genvalidity-sydtest
|
||||
, genvalidity-sydtest-aeson, genvalidity-text, genvalidity-time
|
||||
, lib, openapi3, pretty-show, QuickCheck, safe-coloured-text
|
||||
, scientific, servant-multipart, servant-multipart-api, swagger2
|
||||
, sydtest, sydtest-aeson, sydtest-discover, text, time
|
||||
, unordered-containers, vector, yaml
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "autodocodec-api-usage";
|
||||
@ -26,8 +27,8 @@ mkDerivation {
|
||||
aeson autodocodec autodocodec-nix autodocodec-openapi3
|
||||
autodocodec-schema autodocodec-servant-multipart
|
||||
autodocodec-swagger2 autodocodec-yaml base bytestring containers
|
||||
genvalidity genvalidity-aeson genvalidity-containers
|
||||
genvalidity-scientific genvalidity-sydtest
|
||||
dlist genvalidity genvalidity-aeson genvalidity-containers
|
||||
genvalidity-dlist genvalidity-scientific genvalidity-sydtest
|
||||
genvalidity-sydtest-aeson genvalidity-text genvalidity-time
|
||||
openapi3 pretty-show QuickCheck safe-coloured-text scientific
|
||||
servant-multipart-api swagger2 sydtest sydtest-aeson text time
|
||||
|
@ -63,10 +63,12 @@ tests:
|
||||
- autodocodec-yaml
|
||||
- bytestring
|
||||
- containers
|
||||
- dlist
|
||||
- genvalidity
|
||||
- autodocodec-nix
|
||||
- genvalidity-aeson
|
||||
- genvalidity-containers
|
||||
- genvalidity-dlist
|
||||
- genvalidity-scientific
|
||||
- genvalidity-sydtest
|
||||
- genvalidity-sydtest-aeson
|
||||
|
@ -11,12 +11,16 @@ import Autodocodec
|
||||
import Autodocodec.Schema
|
||||
import Autodocodec.Usage
|
||||
import qualified Data.Aeson as JSON
|
||||
import Data.DList (DList)
|
||||
import Data.DList.DNonEmpty (DNonEmpty)
|
||||
import Data.Data
|
||||
import Data.Functor.Const (Const)
|
||||
import Data.Functor.Identity (Identity)
|
||||
import Data.GenValidity
|
||||
import Data.GenValidity.Aeson ()
|
||||
import Data.GenValidity.Containers ()
|
||||
import Data.GenValidity.DList ()
|
||||
import Data.GenValidity.DNonEmpty ()
|
||||
import Data.GenValidity.Scientific ()
|
||||
import Data.GenValidity.Text ()
|
||||
import Data.GenValidity.Time ()
|
||||
@ -69,7 +73,9 @@ spec = do
|
||||
jsonSchemaSpec @(Either Bool Text) "either-bool-text"
|
||||
jsonSchemaSpec @(Either (Either Bool Scientific) Text) "either-either-bool-scientific-text"
|
||||
jsonSchemaSpec @[Text] "list-text"
|
||||
jsonSchemaSpec @(DList Text) "dlist-text"
|
||||
jsonSchemaSpec @(NonEmpty Text) "nonempty-text"
|
||||
jsonSchemaSpec @(DNonEmpty Text) "nonempty-text"
|
||||
jsonSchemaSpec @(Set Text) "set-text"
|
||||
jsonSchemaSpec @(Map Text Int) "map-text-ind"
|
||||
jsonSchemaSpec @Day "day"
|
||||
|
@ -11,12 +11,16 @@ import Data.Aeson (FromJSON (..), ToJSON (..))
|
||||
import qualified Data.Aeson as JSON
|
||||
import qualified Data.Aeson.Types as JSON
|
||||
import qualified Data.ByteString.Lazy as LB
|
||||
import Data.DList (DList)
|
||||
import Data.DList.DNonEmpty (DNonEmpty)
|
||||
import Data.Data
|
||||
import Data.Functor.Const (Const)
|
||||
import Data.Functor.Identity (Identity)
|
||||
import Data.GenValidity
|
||||
import Data.GenValidity.Aeson ()
|
||||
import Data.GenValidity.Containers ()
|
||||
import Data.GenValidity.DList ()
|
||||
import Data.GenValidity.DNonEmpty ()
|
||||
import Data.GenValidity.Scientific ()
|
||||
import Data.GenValidity.Text ()
|
||||
import Data.GenValidity.Time ()
|
||||
@ -84,7 +88,9 @@ spec = do
|
||||
aesonCodecSpec @(Vector Text)
|
||||
aesonCodecSpec @[Text]
|
||||
aesonCodecErrorSpec @[Text] "list-text-error-string" "\"string\""
|
||||
aesonCodecSpec @(DList Text)
|
||||
aesonCodecSpec @(NonEmpty Text)
|
||||
aesonCodecSpec @(DNonEmpty Text)
|
||||
aesonCodecSpec @(Set Text)
|
||||
aesonCodecSpec @(Map Text Int)
|
||||
aesonCodecSpec @Day
|
||||
|
@ -9,8 +9,12 @@ import Autodocodec
|
||||
import Autodocodec.Nix
|
||||
import Autodocodec.Usage
|
||||
import qualified Data.Aeson as JSON
|
||||
import Data.DList (DList)
|
||||
import Data.DList.DNonEmpty (DNonEmpty)
|
||||
import Data.Functor.Const (Const)
|
||||
import Data.Functor.Identity (Identity)
|
||||
import Data.GenValidity.DList ()
|
||||
import Data.GenValidity.DNonEmpty ()
|
||||
import Data.Int
|
||||
import Data.List.NonEmpty (NonEmpty (..))
|
||||
import Data.Map (Map)
|
||||
@ -56,7 +60,9 @@ spec = do
|
||||
nixOptionTypeSpec @(Either Bool Text) "either-bool-text"
|
||||
nixOptionTypeSpec @(Either (Either Bool Scientific) Text) "either-either-bool-scientific-text"
|
||||
nixOptionTypeSpec @[Text] "list-text"
|
||||
nixOptionTypeSpec @(DList Text) "dlist-text"
|
||||
nixOptionTypeSpec @(NonEmpty Text) "nonempty-text"
|
||||
nixOptionTypeSpec @(DNonEmpty Text) "dnonempty-text"
|
||||
nixOptionTypeSpec @(Set Text) "set-text"
|
||||
nixOptionTypeSpec @(Map Text Int) "map-text-ind"
|
||||
nixOptionTypeSpec @Day "day"
|
||||
|
@ -11,6 +11,8 @@ import Autodocodec.OpenAPI
|
||||
import Autodocodec.OpenAPI.DerivingVia
|
||||
import Autodocodec.Usage
|
||||
import qualified Data.Aeson as JSON
|
||||
import Data.DList (DList)
|
||||
import Data.DList.DNonEmpty (DNonEmpty)
|
||||
import Data.Data
|
||||
import Data.Functor.Const (Const)
|
||||
import Data.Functor.Identity (Identity)
|
||||
@ -81,7 +83,9 @@ spec = do
|
||||
openAPISchemaSpec @(Either (Either Bool Scientific) Text) "either-either-bool-scientific-text"
|
||||
openAPISchemaSpec @(Vector Text) "vector-text"
|
||||
openAPISchemaSpec @[Text] "list-text"
|
||||
openAPISchemaSpec @(DList Text) "dlist-text"
|
||||
openAPISchemaSpec @(NonEmpty Text) "nonempty-text"
|
||||
openAPISchemaSpec @(DNonEmpty Text) "dnonempty-text"
|
||||
openAPISchemaSpec @(Set Text) "set-text"
|
||||
openAPISchemaSpec @(Map Text Int) "map-text-int"
|
||||
openAPISchemaSpec @Day "day"
|
||||
|
@ -8,6 +8,8 @@ module Autodocodec.ShowSpec (spec) where
|
||||
import Autodocodec
|
||||
import Autodocodec.Usage
|
||||
import qualified Data.Aeson as JSON
|
||||
import Data.DList (DList)
|
||||
import Data.DList.DNonEmpty (DNonEmpty)
|
||||
import Data.Data
|
||||
import Data.Functor.Const (Const)
|
||||
import Data.Functor.Identity (Identity)
|
||||
@ -61,7 +63,9 @@ spec = do
|
||||
showCodecSpec @(Either (Either Bool Scientific) Text) "either-either-bool-scientific-text"
|
||||
showCodecSpec @(Vector Text) "vector-text"
|
||||
showCodecSpec @[Text] "list-text"
|
||||
showCodecSpec @(DList Text) "dlist-text"
|
||||
showCodecSpec @(NonEmpty Text) "nonempty-text"
|
||||
showCodecSpec @(DNonEmpty Text) "dnonempty-text"
|
||||
showCodecSpec @(Set Text) "set-text"
|
||||
showCodecSpec @(Map Text Int) "map-text-int"
|
||||
showCodecSpec @Day "day"
|
||||
|
@ -10,12 +10,16 @@ import Autodocodec
|
||||
import Autodocodec.Swagger
|
||||
import Autodocodec.Usage
|
||||
import qualified Data.Aeson as JSON
|
||||
import Data.DList (DList)
|
||||
import Data.DList.DNonEmpty (DNonEmpty)
|
||||
import Data.Data
|
||||
import Data.Functor.Const (Const)
|
||||
import Data.Functor.Identity (Identity)
|
||||
import Data.GenValidity
|
||||
import Data.GenValidity.Aeson ()
|
||||
import Data.GenValidity.Containers ()
|
||||
import Data.GenValidity.DList ()
|
||||
import Data.GenValidity.DNonEmpty ()
|
||||
import Data.GenValidity.Scientific ()
|
||||
import Data.GenValidity.Text ()
|
||||
import Data.GenValidity.Time ()
|
||||
@ -75,7 +79,9 @@ spec = do
|
||||
swaggerSchemaSpec @(Either (Either Bool Scientific) Text) "either-either-bool-scientific-text"
|
||||
swaggerSchemaSpec @(Vector Text) "vector-text"
|
||||
swaggerSchemaSpec @[Text] "list-text"
|
||||
swaggerSchemaSpec @(DList Text) "dlist-text"
|
||||
swaggerSchemaSpec @(NonEmpty Text) "nonempty-text"
|
||||
swaggerSchemaSpec @(DNonEmpty Text) "dnonempty-text"
|
||||
swaggerSchemaSpec @(Set Text) "set-text"
|
||||
swaggerSchemaSpec @(Map Text Int) "map-text-int"
|
||||
swaggerSchemaSpec @Day "day"
|
||||
|
@ -9,12 +9,16 @@ import Autodocodec
|
||||
import Autodocodec.Usage
|
||||
import Autodocodec.Yaml.Encode
|
||||
import qualified Data.Aeson as JSON
|
||||
import Data.DList (DList)
|
||||
import Data.DList.DNonEmpty (DNonEmpty)
|
||||
import Data.Data
|
||||
import Data.Functor.Const (Const)
|
||||
import Data.Functor.Identity (Identity)
|
||||
import Data.GenValidity
|
||||
import Data.GenValidity.Aeson ()
|
||||
import Data.GenValidity.Containers ()
|
||||
import Data.GenValidity.DList ()
|
||||
import Data.GenValidity.DNonEmpty ()
|
||||
import Data.GenValidity.Scientific ()
|
||||
import Data.GenValidity.Text ()
|
||||
import Data.GenValidity.Time ()
|
||||
@ -68,7 +72,9 @@ spec = do
|
||||
yamlCodecSpec @(Either (Either Bool [Text]) Text)
|
||||
yamlCodecSpec @(Vector Text)
|
||||
yamlCodecSpec @[Text]
|
||||
yamlCodecSpec @(DList Text)
|
||||
yamlCodecSpec @(NonEmpty Text)
|
||||
yamlCodecSpec @(DNonEmpty Text)
|
||||
yamlCodecSpec @(Set Text)
|
||||
yamlCodecSpec @(Map Text Int)
|
||||
yamlCodecSpec @Day
|
||||
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
{ lib }:
|
||||
lib.types.listOf lib.types.str
|
@ -0,0 +1,2 @@
|
||||
{ lib }:
|
||||
lib.types.listOf lib.types.str
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"components": {
|
||||
"schemas": {
|
||||
"(DList Text)": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"info": {
|
||||
"title": "",
|
||||
"version": ""
|
||||
},
|
||||
"openapi": "3.0.0",
|
||||
"paths": {}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"components": {
|
||||
"schemas": {
|
||||
"(DNonEmpty Text)": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"info": {
|
||||
"title": "",
|
||||
"version": ""
|
||||
},
|
||||
"openapi": "3.0.0",
|
||||
"paths": {}
|
||||
}
|
@ -0,0 +1 @@
|
||||
BimapCodec _ _ (ArrayOfCodec Nothing (StringCodec Nothing))
|
@ -0,0 +1 @@
|
||||
BimapCodec _ _ (ArrayOfCodec Nothing (StringCodec Nothing))
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"definitions": {
|
||||
"(DList Text)": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"info": {
|
||||
"title": "",
|
||||
"version": ""
|
||||
},
|
||||
"paths": {},
|
||||
"swagger": "2.0"
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"definitions": {
|
||||
"(DNonEmpty Text)": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"info": {
|
||||
"title": "",
|
||||
"version": ""
|
||||
},
|
||||
"paths": {},
|
||||
"swagger": "2.0"
|
||||
}
|
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## [0.4.2.0] - 2024-08-06
|
||||
|
||||
### Added
|
||||
|
||||
* `HasCodec` instances for `DList` and `DNonEmpty` from the `dlist` package.
|
||||
|
||||
## [0.4.1.0] - 2024-08-03
|
||||
|
||||
### Changed
|
||||
|
@ -5,7 +5,7 @@ cabal-version: 1.12
|
||||
-- see: https://github.com/sol/hpack
|
||||
|
||||
name: autodocodec
|
||||
version: 0.4.1.0
|
||||
version: 0.4.2.0
|
||||
synopsis: Self-documenting encoder and decoder
|
||||
homepage: https://github.com/NorfairKing/autodocodec#readme
|
||||
bug-reports: https://github.com/NorfairKing/autodocodec/issues
|
||||
@ -42,6 +42,7 @@ library
|
||||
, base >=4.7 && <5
|
||||
, bytestring
|
||||
, containers
|
||||
, dlist
|
||||
, hashable
|
||||
, mtl
|
||||
, scientific
|
||||
|
@ -1,14 +1,14 @@
|
||||
{ mkDerivation, aeson, base, bytestring, containers, doctest
|
||||
{ mkDerivation, aeson, base, bytestring, containers, dlist, doctest
|
||||
, hashable, lib, mtl, scientific, text, time, unordered-containers
|
||||
, validity, validity-scientific, vector
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "autodocodec";
|
||||
version = "0.4.1.0";
|
||||
version = "0.4.2.0";
|
||||
src = ./.;
|
||||
libraryHaskellDepends = [
|
||||
aeson base bytestring containers hashable mtl scientific text time
|
||||
unordered-containers validity validity-scientific vector
|
||||
aeson base bytestring containers dlist hashable mtl scientific text
|
||||
time unordered-containers validity validity-scientific vector
|
||||
];
|
||||
testHaskellDepends = [ base doctest ];
|
||||
homepage = "https://github.com/NorfairKing/autodocodec#readme";
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: autodocodec
|
||||
version: 0.4.1.0
|
||||
version: 0.4.2.0
|
||||
github: "NorfairKing/autodocodec"
|
||||
license: MIT
|
||||
author: "Tom Sydney Kerckhove"
|
||||
@ -20,6 +20,7 @@ library:
|
||||
- aeson
|
||||
- bytestring
|
||||
- containers
|
||||
- dlist
|
||||
- hashable
|
||||
- mtl
|
||||
- scientific
|
||||
|
@ -19,6 +19,10 @@ import Numeric.Natural
|
||||
#if MIN_VERSION_aeson(2,0,0)
|
||||
import Data.Aeson.KeyMap (KeyMap)
|
||||
#endif
|
||||
import Data.DList (DList)
|
||||
import qualified Data.DList as DList
|
||||
import Data.DList.DNonEmpty (DNonEmpty)
|
||||
import qualified Data.DList.DNonEmpty as DNonEmpty
|
||||
import Data.Functor.Const (Const (Const))
|
||||
import Data.Functor.Identity
|
||||
import Data.HashMap.Strict (HashMap)
|
||||
@ -155,9 +159,15 @@ instance (HasCodec a) => HasCodec (Vector a) where
|
||||
instance (HasCodec a) => HasCodec [a] where
|
||||
codec = listCodecForStringCompatibility
|
||||
|
||||
instance (HasCodec a) => HasCodec (DList a) where
|
||||
codec = dimapCodec DList.fromList DList.toList (codec :: JSONCodec [a])
|
||||
|
||||
instance (HasCodec a) => HasCodec (NonEmpty a) where
|
||||
codec = nonEmptyCodec codec
|
||||
|
||||
instance (HasCodec a) => HasCodec (DNonEmpty a) where
|
||||
codec = dimapCodec DNonEmpty.fromNonEmpty DNonEmpty.toNonEmpty (codec :: JSONCodec (NonEmpty a))
|
||||
|
||||
instance (Ord a, HasCodec a) => HasCodec (Set a) where
|
||||
codec = dimapCodec S.fromList S.toList codec
|
||||
|
||||
|
@ -447,11 +447,11 @@
|
||||
"validity": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1721316458,
|
||||
"narHash": "sha256-hOXmXvapzeXhDfxYwt+h486EFIF0ympbVBoG2bA6isA=",
|
||||
"lastModified": 1722943924,
|
||||
"narHash": "sha256-hq5FwDFW+02u5Qsx8v1KWoQUsY6S6ufI4WYKZ6yhYUA=",
|
||||
"owner": "NorfairKing",
|
||||
"repo": "validity",
|
||||
"rev": "6b06ec70bdd999f7450f88f4beea43f1607e3726",
|
||||
"rev": "51b8843b9bd5228160b99f653d3271147245d689",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -11,15 +11,17 @@ packages:
|
||||
|
||||
extra-deps:
|
||||
- github: NorfairKing/validity
|
||||
commit: 6b06ec70bdd999f7450f88f4beea43f1607e3726
|
||||
commit: 51b8843b9bd5228160b99f653d3271147245d689
|
||||
subdirs:
|
||||
- validity
|
||||
- validity-aeson
|
||||
- validity-containers
|
||||
- validity-dlist
|
||||
- validity-text
|
||||
- genvalidity
|
||||
- genvalidity-aeson
|
||||
- genvalidity-containers
|
||||
- genvalidity-dlist
|
||||
- genvalidity-scientific
|
||||
- genvalidity-sydtest
|
||||
- genvalidity-sydtest-aeson
|
||||
|
Loading…
Reference in New Issue
Block a user