From 3785aaf884a85e6a56d6e29cc5289f24fc40091f Mon Sep 17 00:00:00 2001 From: Tom Sydney Kerckhove Date: Thu, 13 Jun 2024 11:31:59 +0200 Subject: [PATCH] opt-env-conf upgrades --- autodocodec-schema/src/Autodocodec/Schema.hs | 8 ++++---- autodocodec-yaml/autodocodec-yaml.cabal | 1 - autodocodec-yaml/default.nix | 5 ++--- autodocodec-yaml/package.yaml | 1 - autodocodec-yaml/src/Autodocodec/Yaml.hs | 1 + autodocodec-yaml/src/Autodocodec/Yaml/Schema.hs | 6 +++++- autodocodec/src/Autodocodec/Codec.hs | 2 +- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/autodocodec-schema/src/Autodocodec/Schema.hs b/autodocodec-schema/src/Autodocodec/Schema.hs index 1c255a9..fc3603f 100644 --- a/autodocodec-schema/src/Autodocodec/Schema.hs +++ b/autodocodec-schema/src/Autodocodec/Schema.hs @@ -48,14 +48,14 @@ data JSONSchema | ArraySchema !JSONSchema | MapSchema !JSONSchema | -- | This needs to be a list because keys should stay in their original ordering. - ObjectSchema ObjectSchema + ObjectSchema !ObjectSchema | ValueSchema !JSON.Value | AnyOfSchema !(NonEmpty JSONSchema) | OneOfSchema !(NonEmpty JSONSchema) | CommentSchema !Text !JSONSchema | RefSchema !Text | WithDefSchema !(Map Text JSONSchema) !JSONSchema - deriving (Show, Eq, Generic) + deriving (Show, Eq, Ord, Generic) instance Validity JSONSchema where validate js = @@ -167,7 +167,7 @@ data ObjectSchema | ObjectAnyOfSchema !(NonEmpty ObjectSchema) | ObjectOneOfSchema !(NonEmpty ObjectSchema) | ObjectAllOfSchema !(NonEmpty ObjectSchema) - deriving (Show, Eq, Generic) + deriving (Show, Eq, Ord, Generic) instance Validity ObjectSchema @@ -304,7 +304,7 @@ validateAccordingTo val schema = (`evalState` M.empty) $ go val schema data KeyRequirement = Required | Optional !(Maybe JSON.Value) -- Default value - deriving (Show, Eq, Generic) + deriving (Show, Eq, Ord, Generic) instance Validity KeyRequirement diff --git a/autodocodec-yaml/autodocodec-yaml.cabal b/autodocodec-yaml/autodocodec-yaml.cabal index c99b640..676d46e 100644 --- a/autodocodec-yaml/autodocodec-yaml.cabal +++ b/autodocodec-yaml/autodocodec-yaml.cabal @@ -44,7 +44,6 @@ library , safe-coloured-text >=0.2.0.0 , scientific , text - , unordered-containers , vector , yaml default-language: Haskell2010 diff --git a/autodocodec-yaml/default.nix b/autodocodec-yaml/default.nix index 0692328..3a88912 100644 --- a/autodocodec-yaml/default.nix +++ b/autodocodec-yaml/default.nix @@ -1,6 +1,6 @@ { mkDerivation, autodocodec, autodocodec-schema, base, bytestring , containers, lib, path, path-io, safe-coloured-text, scientific -, text, unordered-containers, vector, yaml +, text, vector, yaml }: mkDerivation { pname = "autodocodec-yaml"; @@ -8,8 +8,7 @@ mkDerivation { src = ./.; libraryHaskellDepends = [ autodocodec autodocodec-schema base bytestring containers path - path-io safe-coloured-text scientific text unordered-containers - vector yaml + path-io safe-coloured-text scientific text vector yaml ]; homepage = "https://github.com/NorfairKing/autodocodec#readme"; description = "Autodocodec interpreters for yaml"; diff --git a/autodocodec-yaml/package.yaml b/autodocodec-yaml/package.yaml index d3c1c71..b65c738 100644 --- a/autodocodec-yaml/package.yaml +++ b/autodocodec-yaml/package.yaml @@ -26,6 +26,5 @@ library: - safe-coloured-text >=0.2.0.0 - scientific - text - - unordered-containers - vector - yaml diff --git a/autodocodec-yaml/src/Autodocodec/Yaml.hs b/autodocodec-yaml/src/Autodocodec/Yaml.hs index 6540c91..f450989 100644 --- a/autodocodec-yaml/src/Autodocodec/Yaml.hs +++ b/autodocodec-yaml/src/Autodocodec/Yaml.hs @@ -17,6 +17,7 @@ module Autodocodec.Yaml schemaChunksViaCodec, schemaChunksVia, jsonSchemaChunks, + jsonSchemaChunkLines, -- * Instantiating @ToYaml@ toYamlViaCodec, diff --git a/autodocodec-yaml/src/Autodocodec/Yaml/Schema.hs b/autodocodec-yaml/src/Autodocodec/Yaml/Schema.hs index 33baefd..8fbb80e 100644 --- a/autodocodec-yaml/src/Autodocodec/Yaml/Schema.hs +++ b/autodocodec-yaml/src/Autodocodec/Yaml/Schema.hs @@ -46,7 +46,11 @@ schemaChunksVia = jsonSchemaChunks . jsonSchemaVia -- | Render a 'JSONSchema' as 'Chunk's jsonSchemaChunks :: JSONSchema -> [Chunk] -jsonSchemaChunks = concatMap (\l -> l ++ ["\n"]) . go +jsonSchemaChunks = unlinesChunks . jsonSchemaChunkLines + +-- | Render a 'JSONSchema' as lines of 'Chunk's +jsonSchemaChunkLines :: JSONSchema -> [[Chunk]] +jsonSchemaChunkLines = go where indent :: [[Chunk]] -> [[Chunk]] indent = map (" " :) diff --git a/autodocodec/src/Autodocodec/Codec.hs b/autodocodec/src/Autodocodec/Codec.hs index 5a0edf7..f96c113 100644 --- a/autodocodec/src/Autodocodec/Codec.hs +++ b/autodocodec/src/Autodocodec/Codec.hs @@ -266,7 +266,7 @@ data NumberBounds = NumberBounds { numberBoundsLower :: !Scientific, numberBoundsUpper :: !Scientific } - deriving (Show, Eq, Generic) + deriving (Show, Eq, Ord, Generic) instance Validity NumberBounds