Skip to content

Commit 3dbd2ae

Browse files
committed
WIP
1 parent c0c2cc9 commit 3dbd2ae

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

src/Codec/CBOR/Cuddle/Huddle.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,13 @@ data LiteralVariant where
381381
LBytes :: ByteString -> LiteralVariant
382382
deriving (Show)
383383

384-
int :: Default i => Integer -> Literal i
384+
int :: Integer -> Literal DHuddle
385385
int = inferInteger
386386

387-
bstr :: Default i => ByteString -> Literal i
387+
bstr :: ByteString -> Literal DHuddle
388388
bstr x = Literal (LBytes x) def
389389

390-
text :: Default i => T.Text -> Literal i
390+
text :: T.Text -> Literal DHuddle
391391
text x = Literal (LText x) def
392392

393393
inferInteger :: Default i => Integer -> Literal i
@@ -887,21 +887,21 @@ seal = Seal
887887

888888
-- | This function is used solely to resolve type inference by explicitly
889889
-- identifying something as an array.
890-
arr :: ArrayChoice i -> ArrayChoice i
890+
arr :: ArrayChoice DHuddle -> ArrayChoice DHuddle
891891
arr = id
892892

893893
-- | Create and seal an array, marking it as accepting no additional choices
894-
sarr :: ArrayChoice i -> Seal (Array i)
894+
sarr :: ArrayChoice DHuddle -> Seal (Array DHuddle)
895895
sarr = seal . NoChoice
896896

897-
mp :: MapChoice i -> MapChoice i
897+
mp :: MapChoice DHuddle -> MapChoice DHuddle
898898
mp = id
899899

900900
-- | Create and seal a map, marking it as accepting no additional choices.
901-
smp :: MapChoice i -> Seal (Map i)
901+
smp :: MapChoice DHuddle -> Seal (Map DHuddle)
902902
smp = seal . NoChoice
903903

904-
grp :: Group i -> Group i
904+
grp :: Group DHuddle -> Group DHuddle
905905
grp = id
906906

907907
--------------------------------------------------------------------------------
@@ -1103,7 +1103,7 @@ toCDDL' mkPseudoRoot hdl =
11031103
toTopLevelPseudoRoot topRs =
11041104
toCDDLRule $
11051105
comment "Pseudo-rule introduced by Cuddle to collect root elements" $
1106-
"huddle_root_defs" =:= arr @DHuddle (fromList (fmap a topRs))
1106+
"huddle_root_defs" =:= arr (fromList (fmap a topRs))
11071107
toCDDLRule :: Rule DHuddle -> C.Rule DHuddle
11081108
toCDDLRule (Named n t0 c) =
11091109
(\x -> C.Rule (C.Name n mempty) Nothing C.AssignEq x c)

test/Test/Codec/CBOR/Cuddle/CDDL/Examples.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Codec.CBOR.Cuddle.CDDL.Prelude (prependPrelude)
44
import Codec.CBOR.Cuddle.CDDL.Resolve (fullResolveCDDL)
55
import Codec.CBOR.Cuddle.Parser (pCDDL)
66
import Data.Either (isRight)
7+
import Data.Functor (($>))
78
import Data.Text.IO qualified as T
89
import Test.Hspec
910
import Text.Megaparsec (parse)
@@ -15,7 +16,7 @@ validateFile filePath = it ("Successfully validates " <> filePath) $ do
1516
cddl <- case parse pCDDL "" contents of
1617
Right x -> pure $ prependPrelude x
1718
Left x -> fail $ "Failed to parse the file:\n" <> errorBundlePretty x
18-
fullResolveCDDL cddl `shouldSatisfy` isRight
19+
fullResolveCDDL (cddl $> ()) `shouldSatisfy` isRight
1920

2021
spec :: Spec
2122
spec = do

test/Test/Codec/CBOR/Cuddle/CDDL/Gen.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ instance Arbitrary i => Arbitrary (MemberKey i) where
192192

193193
shrink = genericShrink
194194

195-
instance Arbitrary Value where
195+
instance Arbitrary i => Arbitrary (Value i) where
196196
arbitrary = Value <$> arbitrary <*> arbitrary
197197
shrink = genericShrink
198198

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ nestedSpec =
119119
genericSpec :: Spec
120120
genericSpec =
121121
describe "Generics" $
122-
let set :: IsType0 t0 => t0 -> GRuleCall
122+
let set :: IsType0 t0 => t0 -> GRuleCall DHuddle
123123
set = binding $ \x -> "set" =:= arr [0 <+ a x]
124124

125-
dict :: (IsType0 t0, IsType0 t1) => t0 -> t1 -> GRuleCall
125+
dict :: (IsType0 t0, IsType0 t1) => t0 -> t1 -> GRuleCall DHuddle
126126
dict = binding2 $ \k v -> "dict" =:= mp [0 <+ asKey k ==> v]
127127
in do
128128
it "Should bind a single parameter" $
@@ -162,5 +162,5 @@ shouldMatchParseCDDL ::
162162
Expectation
163163
shouldMatchParseCDDL x = shouldMatchParse x pCDDL
164164

165-
toSortedCDDLPretty :: Huddle -> CDDL Comment
166-
toSortedCDDLPretty = sortCDDL . toCDDLNoRoot
165+
toSortedCDDLPretty :: Huddle DHuddle -> CDDL Comment
166+
toSortedCDDLPretty = sortCDDL . fmap dhComment . toCDDLNoRoot

0 commit comments

Comments
 (0)