diff options
| author | krasimir <krasimir@chalmers.se> | 2010-09-22 15:49:16 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2010-09-22 15:49:16 +0000 |
| commit | 617ce3cce67acca54a1ef3127da91bcd3e6a12ab (patch) | |
| tree | df716486c8cb4b09c248fb236ced79494f6860b4 /src/compiler/GF/Command/Commands.hs | |
| parent | 1c9305e7a39f4d17d4300067e987e3ebc30e83f3 (diff) | |
the first revision of exhaustive and random generation with dependent types. Still not quite stable.
Diffstat (limited to 'src/compiler/GF/Command/Commands.hs')
| -rw-r--r-- | src/compiler/GF/Command/Commands.hs | 15 |
1 files changed, 10 insertions, 5 deletions
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 { |
