@@ -37,6 +37,8 @@ import Data.Functor.Identity (Identity (runIdentity))
37
37
import Data.List.NonEmpty qualified as NE
38
38
import Data.Map.Strict qualified as Map
39
39
import Data.Maybe (fromMaybe )
40
+ import Data.Text (Text )
41
+ import Data.Text qualified as T
40
42
import Data.Word (Word64 )
41
43
import GHC.Generics (Generic )
42
44
import System.Random.Stateful
@@ -131,6 +133,9 @@ genRandomM = asksM @"fakeSeed" randomM
131
133
genBytes :: forall g . (RandomGen g ) => Int -> M g ByteString
132
134
genBytes n = asksM @ " fakeSeed" $ uniformByteStringM n
133
135
136
+ genText :: forall g . (RandomGen g ) => Int -> M g Text
137
+ genText n = pure $ T. pack $ take n [' a' .. ]
138
+
134
139
--------------------------------------------------------------------------------
135
140
-- Combinators
136
141
--------------------------------------------------------------------------------
@@ -274,6 +279,7 @@ genForCTree (CTree.Control op target controller) = do
274
279
ct <- resolveIfRef controller
275
280
case (op, ct) of
276
281
(CtlOp. Size , CTree. Literal (VUInt n)) -> case tt of
282
+ CTree. Postlude PTText -> S . TString <$> genText (fromIntegral n)
277
283
CTree. Postlude PTBytes -> S . TBytes <$> genBytes (fromIntegral n)
278
284
CTree. Postlude PTUInt -> S . TInteger <$> genUniformRM (0 , 2 ^ n - 1 )
279
285
_ -> error " Cannot apply size operator to target "
@@ -282,6 +288,9 @@ genForCTree (CTree.Control op target controller) = do
282
288
t <- resolveIfRef to
283
289
case (f, t) of
284
290
(CTree. Literal (VUInt f1), CTree. Literal (VUInt t1)) -> case tt of
291
+ CTree. Postlude PTText ->
292
+ genUniformRM (fromIntegral f1, fromIntegral t1)
293
+ >>= (fmap (S . TString ) . genText)
285
294
CTree. Postlude PTBytes ->
286
295
genUniformRM (fromIntegral f1, fromIntegral t1)
287
296
>>= (fmap (S . TBytes ) . genBytes)
0 commit comments