Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0bf20cd
Add TermGenerator
Nov 9, 2026
63bbcfb
WIP
Nov 10, 2026
7707ed2
WIP
Nov 16, 2026
c487075
WIP
Nov 17, 2026
07469c8
WIP
Nov 17, 2026
e0f4a8f
Add deferGen
Nov 17, 2026
d57e317
WIP
Nov 17, 2026
73a53f5
make QC size bounds soft not hard caps
Nov 17, 2026
f3a3d00
Implement integer constraints
Nov 17, 2026
eb96381
Implement cbor constraint
Nov 17, 2026
9c7a9c9
Add Interval module
Nov 17, 2026
da38163
Add CTreeE cases to evalInterval
Nov 19, 2026
8a57610
Remove twiddler
Nov 19, 2026
de17723
Export some helpers
Nov 19, 2026
eb292fd
Add IsConstrainable to Rule
Nov 20, 2026
824d2e4
Remove AnyRef in favor of Rule
Nov 20, 2026
e28d891
Give custom generators access to the original generator
Nov 20, 2026
1f4be93
Rename Gen module to Generator
Nov 23, 2026
c7084ee
Reorganize modules
Nov 24, 2026
b736f0a
Implement new validator monad
Nov 24, 2026
c9f62bc
Block indexed validator monad
Nov 24, 2026
f293635
All done except array and map validation
Nov 25, 2026
339d923
List validator basically done
Nov 25, 2026
1900b88
List validator fixes
Nov 25, 2026
af43a97
Map validation almost done
Nov 26, 2026
8891f0e
Map validation fixes
Nov 26, 2026
11ea3a9
Map duplicate keys check
Nov 26, 2026
b023932
Implement closestMatch
Nov 26, 2026
566a044
Compiles
Nov 26, 2026
ebd85ad
Add ref steps
Nov 26, 2026
23ead0e
Fix test failures
Nov 26, 2026
42ad61e
Make custom validators overridable
Nov 27, 2026
b8e69a6
Generalize eval functions
Nov 27, 2026
afe75c2
Simplify validator
Nov 27, 2026
5185391
Fix some bugs
Nov 27, 2026
2b60311
Minor fixes
Nov 27, 2026
91b60d9
Pass length encoding
Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions bin/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,25 @@

module Main (main) where

import Codec.CBOR.Cuddle.CBOR.Gen (generateFromName)
import Codec.CBOR.Cuddle.CBOR.Generator (generateFromName)
import Codec.CBOR.Cuddle.CBOR.Validator
import Codec.CBOR.Cuddle.CBOR.Validator.Trace (
Evidenced (..),
SValidity (..),
TraceOptions (..),
prettyValidationTrace,
)
import Codec.CBOR.Cuddle.CDDL (CDDL, Name (..), fromRules, sortCDDL)
import Codec.CBOR.Cuddle.CDDL (CDDL, Name (..), fromRules, mapCDDLDropExt, sortCDDL)
import Codec.CBOR.Cuddle.CDDL.CTree (CTreeRoot)
import Codec.CBOR.Cuddle.CDDL.Custom.Generator (
GenConfig (..),
runCBORGen,
twiddleAll,
twiddleNothing,
)
import Codec.CBOR.Cuddle.CDDL.Custom.Validator (
Evidenced (..),
SValidity (..),
TraceOptions (..),
prettyStepTrace,
)
import Codec.CBOR.Cuddle.CDDL.Postlude (appendPostlude)
import Codec.CBOR.Cuddle.CDDL.Resolve (
fullResolveCDDL,
)
import Codec.CBOR.Cuddle.IndexMappable (IndexMappable (..), mapCDDLDropExt)
import Codec.CBOR.Cuddle.IndexMappable (IndexMappable (..))
import Codec.CBOR.Cuddle.Parser (ParserStage, pCDDL)
import Codec.CBOR.Cuddle.Pretty (PrettyStage, renderCDDL)
import Codec.CBOR.FlatTerm (toFlatTerm)
Expand Down Expand Up @@ -404,10 +402,7 @@ run = \case
| goNegative = 1
| otherwise = 0
cfg =
GenConfig
{ gcRoot = mapIndex mt
, gcTwiddle = if goTwiddle then twiddleAll else twiddleNothing
}
GenConfig $ mapIndex mt
term = runGen seed goSize . zapAntiGen zapN . runCBORGen cfg $ generateFromName (Name itemName)
formatted = formatTerm term outputFormat
case outputTo of
Expand Down Expand Up @@ -456,7 +451,7 @@ runValidateCBOR bs rule cddl traceOpts =
exitFailure
Right (Evidenced validity trc) -> do
T.putStrLn . Ansi.renderStrict . layoutPretty defaultLayoutOptions $
prettyValidationTrace traceOpts trc
prettyStepTrace traceOpts trc
putStrLn mempty
case validity of
SValid -> do
Expand Down
6 changes: 3 additions & 3 deletions cuddle.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ library
import: warnings
exposed-modules:
Codec.CBOR.Cuddle.CBOR.Canonical
Codec.CBOR.Cuddle.CBOR.Gen
Codec.CBOR.Cuddle.CBOR.Generator
Codec.CBOR.Cuddle.CBOR.Validator
Codec.CBOR.Cuddle.CBOR.Validator.Trace
Codec.CBOR.Cuddle.CDDL
Codec.CBOR.Cuddle.CDDL.CTree
Codec.CBOR.Cuddle.CDDL.CTreePhase
Codec.CBOR.Cuddle.CDDL.CtlOp
Codec.CBOR.Cuddle.CDDL.Custom.Core
Codec.CBOR.Cuddle.CDDL.Custom.Generator
Codec.CBOR.Cuddle.CDDL.Custom.Validator
Codec.CBOR.Cuddle.CDDL.Phase
Codec.CBOR.Cuddle.CDDL.Postlude
Codec.CBOR.Cuddle.CDDL.Resolve
Codec.CBOR.Cuddle.Comments
Codec.CBOR.Cuddle.Huddle
Codec.CBOR.Cuddle.IndexMappable
Codec.CBOR.Cuddle.Interval
Codec.CBOR.Cuddle.Parser
Codec.CBOR.Cuddle.Parser.Lexer
Codec.CBOR.Cuddle.Pretty
Expand Down
13 changes: 7 additions & 6 deletions example/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

module Main (main) where

import Codec.CBOR.Cuddle.CBOR.Gen (generateFromName)
import Codec.CBOR.Cuddle.CDDL (Name (..))
import Codec.CBOR.Cuddle.CDDL.Custom.Generator (GenConfig (..), runCBORGen, twiddleAll)
import Codec.CBOR.Cuddle.CDDL.Resolve (MonoSimplePhase, fullResolveCDDL)
import Codec.CBOR.Cuddle.CBOR.Generator (generateFromName)
import Codec.CBOR.Cuddle.CDDL (Name (..), mapCDDLDropExt)
import Codec.CBOR.Cuddle.CDDL.Custom.Generator (GenConfig (..), runCBORGen)
import Codec.CBOR.Cuddle.CDDL.Phase (MonoSimplePhase)
import Codec.CBOR.Cuddle.CDDL.Resolve (fullResolveCDDL)
import Codec.CBOR.Cuddle.Huddle (toCDDL)
import Codec.CBOR.Cuddle.IndexMappable (IndexMappable (..), mapCDDLDropExt)
import Codec.CBOR.Cuddle.IndexMappable (IndexMappable (..))
import Codec.CBOR.Cuddle.Parser (pCDDL)
import Codec.CBOR.Cuddle.Pretty (PrettyStage)
import Conway (conway)
Expand Down Expand Up @@ -49,7 +50,7 @@ main = do
case fullResolveCDDL (mapCDDLDropExt res) of
Left nre -> error $ show nre
Right resolved -> do
let cfg = GenConfig {gcRoot = mapIndex resolved, gcTwiddle = twiddleAll}
let cfg = GenConfig {gcRoot = mapIndex resolved}
term <- generate . runAntiGen . runCBORGen cfg $ generateFromName (Name (T.pack name))
print term
[] -> do
Expand Down
10 changes: 8 additions & 2 deletions golden/cborControlBad.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
unsatisfied control:
.cbor simpleRule
app: bytes
ctrl: .cbor [1, 2, 3] (failed)
└ array
└ app: 1
app: 2
failed to apply required rule:
└ failed to apply:
3
7 changes: 3 additions & 4 deletions golden/huddleRangeArrayTwoStrings.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
array
└ app: int
app: int
app: text
app: text
required rule not satisfied:
1* text
failed to apply required rule:
└ failed to apply:
int
2 changes: 1 addition & 1 deletion golden/mapLeftoverKV.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ map
? 2 ==> int
└ key:
└ app: 2
value: (fail)
value: (failed)
└ failed to apply:
int
2 changes: 1 addition & 1 deletion golden/mapNestedValue.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ map
? 1 ==> bar
└ key:
└ app: 1
value: (fail)
value: (failed)
└ ref: bar
└ array
└ app: int
Expand Down
2 changes: 2 additions & 0 deletions src/Codec/CBOR/Cuddle/CBOR/Canonical.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ module Codec.CBOR.Cuddle.CBOR.Canonical (
toCanonical,
uintMax,
nintMin,
unsignedToBytes,
bytesToUnsigned,
) where

import Codec.CBOR.Term (Term (..))
Expand Down
Loading
Loading