Loading src/random-wta/Generator.hs +3 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,9 @@ runGenerator config action = runReaderT action config genMonoidValue :: Generator m m genMonoidValue = asks ((monoid . spec) &&& differentValues) >>= \case (Powerset, Nothing) -> liftIO $ randomIO (Powerset, _) -> error $ "differentValues not supported for powerset" -- FIXME detect this early (and handle the case <=2) (Powerset, Just 1) -> return True (Powerset, Just 2) -> liftIO $ randomIO (Powerset, _) -> error $ "differentValues >2 not supported for powerset" (OrWord, Nothing) -> liftIO $ randomIO (OrWord, Just x) -> liftIO $ randomRIO (1, fromIntegral x) (MaxInt, Nothing) -> liftIO $ randomIO Loading src/random-wta/Main.hs +9 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ import qualified Text.Megaparsec.Char.Lexer as Mega import Data.Void import System.Random import Numeric import System.IO import System.Exit import Types import Generator Loading Loading @@ -115,6 +117,13 @@ main = do Options.info (parseOpts Options.<**> Options.helper) (Options.fullDesc) opts <- Options.execParser optSpec case optMonoid opts of SomeMonoid Powerset | maybe False (>2) (optDifferentValues opts) -> do hPutStrLn stderr "error: Powerset can't have more than 2 different values" exitFailure _ -> return () case optRandomState opts of Nothing -> return () Just x -> setStdGen x Loading src/random-wta/Types.hs +0 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ data MonoidType m where OrWord ::MonoidType Word Powerset ::MonoidType Bool -- | For each arity, the number of symbols type SymbolSpec = Vector Int Loading Loading
src/random-wta/Generator.hs +3 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,9 @@ runGenerator config action = runReaderT action config genMonoidValue :: Generator m m genMonoidValue = asks ((monoid . spec) &&& differentValues) >>= \case (Powerset, Nothing) -> liftIO $ randomIO (Powerset, _) -> error $ "differentValues not supported for powerset" -- FIXME detect this early (and handle the case <=2) (Powerset, Just 1) -> return True (Powerset, Just 2) -> liftIO $ randomIO (Powerset, _) -> error $ "differentValues >2 not supported for powerset" (OrWord, Nothing) -> liftIO $ randomIO (OrWord, Just x) -> liftIO $ randomRIO (1, fromIntegral x) (MaxInt, Nothing) -> liftIO $ randomIO Loading
src/random-wta/Main.hs +9 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ import qualified Text.Megaparsec.Char.Lexer as Mega import Data.Void import System.Random import Numeric import System.IO import System.Exit import Types import Generator Loading Loading @@ -115,6 +117,13 @@ main = do Options.info (parseOpts Options.<**> Options.helper) (Options.fullDesc) opts <- Options.execParser optSpec case optMonoid opts of SomeMonoid Powerset | maybe False (>2) (optDifferentValues opts) -> do hPutStrLn stderr "error: Powerset can't have more than 2 different values" exitFailure _ -> return () case optRandomState opts of Nothing -> return () Just x -> setStdGen x Loading
src/random-wta/Types.hs +0 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ data MonoidType m where OrWord ::MonoidType Word Powerset ::MonoidType Bool -- | For each arity, the number of symbols type SymbolSpec = Vector Int Loading