diff options
| author | aarneranta <aarne@chalmers.se> | 2025-01-07 11:20:23 +0100 |
|---|---|---|
| committer | aarneranta <aarne@chalmers.se> | 2025-01-07 11:20:23 +0100 |
| commit | bc56b54dd12854c2e805dc597f906f879c46d908 (patch) | |
| tree | c4f47f1128ea54d2b81efaa7cd6670fb1ac7c3a1 | |
| parent | aa061aff0ce24c19ea36104744a586add27e3e71 (diff) | |
random generation of literals now has ten different values for each built in type; maybe a better solution for most cases than just one value
| -rw-r--r-- | src/runtime/haskell/PGF/TypeCheck.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/runtime/haskell/PGF/TypeCheck.hs b/src/runtime/haskell/PGF/TypeCheck.hs index c5cc44b4e..82bd47b7a 100644 --- a/src/runtime/haskell/PGF/TypeCheck.hs +++ b/src/runtime/haskell/PGF/TypeCheck.hs @@ -147,9 +147,9 @@ typeGenerators scope cat = fmap normalize (liftM2 (++) x y) where Scope gamma = scope - y | cat == cidInt = return [(1.0,ELit (LInt 999), TTyp [] (DTyp [] cat []))] - | cat == cidFloat = return [(1.0,ELit (LFlt 3.14), TTyp [] (DTyp [] cat []))] - | cat == cidString = return [(1.0,ELit (LStr "Foo"),TTyp [] (DTyp [] cat []))] + y | cat == cidInt = return [(0.1, ELit (LInt n), TTyp [] (DTyp [] cat [])) | n <- ints] + | cat == cidFloat = return [(0.1, ELit (LFlt d), TTyp [] (DTyp [] cat [])) | d <- floats] + | cat == cidString = return [(0.1, ELit (LStr s),TTyp [] (DTyp [] cat [])) | s <- strs] | otherwise = TcM (\abstr k h ms -> case Map.lookup cat (cats abstr) of Just (_,fns,_) -> unTcM (mapM helper fns) abstr k h ms @@ -163,6 +163,11 @@ typeGenerators scope cat = fmap normalize (liftM2 (++) x y) where s = sum [p | (p,_,_) <- gens] + -- random elements of predefined types: many instead of one AR 2025-01-17 + ints = [1, 2, 3, 14, 42, 123, 999, 2025, 1000000, 1234567890] + floats = [0.0, 1.0, 3.14, 0.999, 0.5772156649, 2.71828, 6.62607015, 19.3, 0.0001, 1.60934] + strs = words "A B X Y b c x y foo bar" + emptyMetaStore :: MetaStore s emptyMetaStore = IntMap.empty |
