Skip to content

Commit b7d874c

Browse files
committed
Add range generation for a wider range of types.
1 parent 22a595a commit b7d874c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cuddle.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.4
22
name: cuddle
3-
version: 0.1.3.0
3+
version: 0.1.6.0
44
synopsis: CDDL Generator and test utilities
55

66
-- description:

src/Codec/CBOR/Cuddle/CBOR/Gen.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,13 @@ genForCTree (CTree.Range from to _bounds) = do
262262
term1 <- genForNode from
263263
term2 <- genForNode to
264264
case (term1, term2) of
265+
(S (TInt a), S (TInt b)) -> genUniformRM (a, b) <&> S . TInt
266+
(S (TInt a), S (TInteger b)) -> genUniformRM (fromIntegral a, b) <&> S . TInteger
265267
(S (TInteger a), S (TInteger b)) -> genUniformRM (a, b) <&> S . TInteger
266268
(S (THalf a), S (THalf b)) -> genUniformRM (a, b) <&> S . THalf
267269
(S (TFloat a), S (TFloat b)) -> genUniformRM (a, b) <&> S . TFloat
268270
(S (TDouble a), S (TDouble b)) -> genUniformRM (a, b) <&> S . TDouble
269-
_ -> error "Cannot apply range operator to non-numeric types"
271+
x -> error $ "Cannot apply range operator to non-numeric types: " <> show x
270272
genForCTree (CTree.Control op target controller) = do
271273
tt <- resolveIfRef target
272274
ct <- resolveIfRef controller

0 commit comments

Comments
 (0)