Commit e7905578 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel 🐢
Browse files

wta: Allow --different-values for powerset

Even if it only allows a range of [1,2], it's there for completeness and makes
the benchmark script a bit easier.
parent 719c0a4d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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
+9 −0
Original line number Diff line number Diff line
@@ -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
@@ -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
+0 −1
Original line number Diff line number Diff line
@@ -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