From 617ce3cce67acca54a1ef3127da91bcd3e6a12ab Mon Sep 17 00:00:00 2001 From: krasimir Date: Wed, 22 Sep 2010 15:49:16 +0000 Subject: the first revision of exhaustive and random generation with dependent types. Still not quite stable. --- src/compiler/GF/Command/Commands.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/compiler/GF/Command/Commands.hs') diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs index a9a472552..63e3208b5 100644 --- a/src/compiler/GF/Command/Commands.hs +++ b/src/compiler/GF/Command/Commands.hs @@ -312,8 +312,12 @@ allCommands env@(pgf, mos) = Map.fromList [ let pgfr = optRestricted opts gen <- newStdGen mprobs <- optProbs opts pgfr - let mt = mexp xs - ts <- return $ generateRandomFrom mt mprobs gen pgfr (optType opts) + let sel = case mprobs of + Just probs -> WeightSel gen probs + Nothing -> RandSel gen + let ts = case mexp xs of + Just ex -> generateRandomFrom sel pgfr ex + Nothing -> generateRandom sel pgfr (optType opts) returnFromExprs $ take (optNum opts) ts }), ("gt", emptyCommandInfo { @@ -339,9 +343,10 @@ allCommands env@(pgf, mos) = Map.fromList [ ], exec = \opts xs -> do let pgfr = optRestricted opts - let dp = return $ valIntOpts "depth" 4 opts - let mt = mexp xs - let ts = generateAllDepth mt pgfr (optType opts) dp + let dp = valIntOpts "depth" 4 opts + let ts = case mexp xs of + Just ex -> generateFromDepth pgfr ex (Just dp) + Nothing -> generateAllDepth pgfr (optType opts) (Just dp) returnFromExprs $ take (optNumInf opts) ts }), ("h", emptyCommandInfo { -- cgit v1.2.3