Skip to content

Commit 8f90c72

Browse files
committed
Allow collecting from multiple rules.
1 parent 14ded25 commit 8f90c72

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

example/Conway.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import GHC.Show (Show (show))
2020
default (Integer, Double)
2121

2222
conway :: Huddle
23-
conway = collectFrom block
23+
conway = collectFrom [block]
2424

2525
block :: Rule
2626
block =

src/Codec/CBOR/Cuddle/Huddle.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -789,11 +789,11 @@ binding2 fRule t0 t1 =
789789
--------------------------------------------------------------------------------
790790

791791
-- | Collect all rules starting from a given point.
792-
collectFrom :: Rule -> Huddle
793-
collectFrom topR =
792+
collectFrom :: [Rule] -> Huddle
793+
collectFrom topRs =
794794
toHuddle $
795795
execState
796-
(goRule topR)
796+
(traverse goRule topRs)
797797
(HaskMap.empty, HaskMap.empty, HaskMap.empty)
798798
where
799799
toHuddle (rules, groups, gRules) =

test/Test/Codec/CBOR/Cuddle/Huddle.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ genericSpec =
105105
dict = binding2 $ \k v -> "dict" =:= mp [0 <+ asKey k ==> v]
106106
in do
107107
it "Should bind a single parameter" $
108-
toCDDL (collectFrom ("intset" =:= set VUInt))
108+
toCDDL (collectFrom ["intset" =:= set VUInt])
109109
`shouldMatchParseCDDL` "intset = set<uint>\n set<a0> = [* a0]"
110110
it "Should bind two parameters" $
111-
toCDDL (collectFrom ("mymap" =:= dict VUInt VText))
111+
toCDDL (collectFrom ["mymap" =:= dict VUInt VText])
112112
`shouldMatchParseCDDL` "mymap = dict<uint, text>\n dict<a0, b0> = {* a0 => b0}"
113113

114114
--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)