Skip to content

Commit fe15cf2

Browse files
committed
Add support for .le and .lt operators in Gen
1 parent 5901dc6 commit fe15cf2

File tree

1 file changed

+8
-0
lines changed
  • src/Codec/CBOR/Cuddle/CBOR

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,14 @@ genForCTree (CTree.Control op target controller) = do
308308
tt <- resolveIfRef target
309309
ct <- resolveIfRef controller
310310
case (op, ct) of
311+
(CtlOp.Le, CTree.Literal (VUInt n)) -> case tt of
312+
CTree.Postlude PTUInt -> S. TInteger <$> genUniformRM (0, fromIntegral n)
313+
_ -> error "Cannot apply le operator to target"
314+
(CtlOp.Le, _) -> error $ "Invalid controller for .le operator: " <> show controller
315+
(CtlOp.Lt, CTree.Literal (VUInt n)) -> case tt of
316+
CTree.Postlude PTUInt -> S. TInteger <$> genUniformRM (0, fromIntegral n - 1)
317+
_ -> error "Cannot apply lt operator to target"
318+
(CtlOp.Lt, _) -> error $ "Invalid controller for .lt operator: " <> show controller
311319
(CtlOp.Size, CTree.Literal (VUInt n)) -> case tt of
312320
CTree.Postlude PTText -> S . TString <$> genText (fromIntegral n)
313321
CTree.Postlude PTBytes -> S . TBytes <$> genBytes (fromIntegral n)

0 commit comments

Comments
 (0)