{-# LANGUAGE OverloadedStrings, TupleSections, FlexibleContexts #-}
module Funcons.RunOptions where
import Funcons.Types
import Funcons.GLLParser (Parser(..), pFunconsSeq, pFuncons, fct_lexerSettings)
import Funcons.Parser (fct_parse)
import GLL.Combinators hiding (chooses)
import qualified Data.Map as M
import Control.Monad (when)
import GLL.Types.TypeCompose (OO(..))
import Data.Text (pack)
import Data.List (isSuffixOf, isPrefixOf)
import Data.List.Split (splitOn)
import System.Directory (doesFileExist)
type GeneralOptions = M.Map Name String
type BuiltinFunconsOptions = M.Map Name Funcons
type TestOptions = M.Map Name [Funcons]
type InputValues = M.Map Name [Values]
data RunOptions = RunOptions {
RunOptions -> Maybe Funcons
mfuncon_term :: Maybe Funcons
, RunOptions -> GeneralOptions
general_opts :: GeneralOptions
, RunOptions -> BuiltinFunconsOptions
builtin_funcons :: BuiltinFunconsOptions
, RunOptions -> TestOptions
expected_outcomes :: TestOptions
, RunOptions -> InputValues
given_inputs :: InputValues
}
data SourceOfND =
NDRuleSelection
| NDPatternMatching
| NDInterleaving
| NDValueOperations
deriving (Int -> SourceOfND
SourceOfND -> Int
SourceOfND -> [SourceOfND]
SourceOfND -> SourceOfND
SourceOfND -> SourceOfND -> [SourceOfND]
SourceOfND -> SourceOfND -> SourceOfND -> [SourceOfND]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: SourceOfND -> SourceOfND -> SourceOfND -> [SourceOfND]
$cenumFromThenTo :: SourceOfND -> SourceOfND -> SourceOfND -> [SourceOfND]
enumFromTo :: SourceOfND -> SourceOfND -> [SourceOfND]
$cenumFromTo :: SourceOfND -> SourceOfND -> [SourceOfND]
enumFromThen :: SourceOfND -> SourceOfND -> [SourceOfND]
$cenumFromThen :: SourceOfND -> SourceOfND -> [SourceOfND]
enumFrom :: SourceOfND -> [SourceOfND]
$cenumFrom :: SourceOfND -> [SourceOfND]
fromEnum :: SourceOfND -> Int
$cfromEnum :: SourceOfND -> Int
toEnum :: Int -> SourceOfND
$ctoEnum :: Int -> SourceOfND
pred :: SourceOfND -> SourceOfND
$cpred :: SourceOfND -> SourceOfND
succ :: SourceOfND -> SourceOfND
$csucc :: SourceOfND -> SourceOfND
Enum, Eq SourceOfND
SourceOfND -> SourceOfND -> Bool
SourceOfND -> SourceOfND -> Ordering
SourceOfND -> SourceOfND -> SourceOfND
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SourceOfND -> SourceOfND -> SourceOfND
$cmin :: SourceOfND -> SourceOfND -> SourceOfND
max :: SourceOfND -> SourceOfND -> SourceOfND
$cmax :: SourceOfND -> SourceOfND -> SourceOfND
>= :: SourceOfND -> SourceOfND -> Bool
$c>= :: SourceOfND -> SourceOfND -> Bool
> :: SourceOfND -> SourceOfND -> Bool
$c> :: SourceOfND -> SourceOfND -> Bool
<= :: SourceOfND -> SourceOfND -> Bool
$c<= :: SourceOfND -> SourceOfND -> Bool
< :: SourceOfND -> SourceOfND -> Bool
$c< :: SourceOfND -> SourceOfND -> Bool
compare :: SourceOfND -> SourceOfND -> Ordering
$ccompare :: SourceOfND -> SourceOfND -> Ordering
Ord, SourceOfND -> SourceOfND -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceOfND -> SourceOfND -> Bool
$c/= :: SourceOfND -> SourceOfND -> Bool
== :: SourceOfND -> SourceOfND -> Bool
$c== :: SourceOfND -> SourceOfND -> Bool
Eq)
defaultSources :: [a]
defaultSources = []
instance Show SourceOfND where
show :: SourceOfND -> [Char]
show SourceOfND
NDPatternMatching = [Char]
"pattern-matching"
show SourceOfND
NDInterleaving = [Char]
"interleaving-of-args"
show SourceOfND
NDValueOperations = [Char]
"value-operations"
show SourceOfND
NDRuleSelection = [Char]
"rules"
defaultRunOptions :: RunOptions
defaultRunOptions :: RunOptions
defaultRunOptions = Maybe Funcons
-> GeneralOptions
-> BuiltinFunconsOptions
-> TestOptions
-> InputValues
-> RunOptions
RunOptions forall a. Maybe a
Nothing forall k a. Map k a
M.empty forall k a. Map k a
M.empty forall k a. Map k a
M.empty forall k a. Map k a
M.empty
optionsOverride :: RunOptions -> RunOptions -> RunOptions
optionsOverride RunOptions
opts RunOptions
opts' = Maybe Funcons
-> GeneralOptions
-> BuiltinFunconsOptions
-> TestOptions
-> InputValues
-> RunOptions
RunOptions
(forall b a. b -> (a -> b) -> Maybe a -> b
maybe (RunOptions -> Maybe Funcons
mfuncon_term RunOptions
opts) forall a. a -> Maybe a
Just (RunOptions -> Maybe Funcons
mfuncon_term RunOptions
opts'))
(RunOptions -> GeneralOptions
general_opts RunOptions
opts forall k a. Ord k => Map k a -> Map k a -> Map k a
`M.union` RunOptions -> GeneralOptions
general_opts RunOptions
opts')
(RunOptions -> BuiltinFunconsOptions
builtin_funcons RunOptions
opts forall k a. Ord k => Map k a -> Map k a -> Map k a
`M.union` RunOptions -> BuiltinFunconsOptions
builtin_funcons RunOptions
opts')
(RunOptions -> TestOptions
expected_outcomes RunOptions
opts forall k a. Ord k => Map k a -> Map k a -> Map k a
`M.union` RunOptions -> TestOptions
expected_outcomes RunOptions
opts')
(RunOptions -> InputValues
given_inputs RunOptions
opts forall k a. Ord k => Map k a -> Map k a -> Map k a
`M.union` RunOptions -> InputValues
given_inputs RunOptions
opts')
funcon_term :: RunOptions -> Funcons
funcon_term :: RunOptions -> Funcons
funcon_term = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall {a}. a
err forall a. a -> a
id forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> Maybe Funcons
mfuncon_term
where err :: a
err = forall a. HasCallStack => [Char] -> a
error [Char]
"Please give a .fct file as an argument or use the --funcon-term flag"
bool_opt_default :: Bool -> Name -> M.Map Name String -> Bool
bool_opt_default :: Bool -> Name -> GeneralOptions -> Bool
bool_opt_default Bool
def Name
nm GeneralOptions
m = case forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Name
nm GeneralOptions
m of
Maybe [Char]
Nothing -> Bool
def
Just [Char]
"false" -> Bool
False
Maybe [Char]
_ -> Bool
True
bool_opt :: Name -> M.Map Name String -> Bool
bool_opt :: Name -> GeneralOptions -> Bool
bool_opt Name
nm GeneralOptions
m = Bool -> Name -> GeneralOptions -> Bool
bool_opt_default Bool
False Name
nm GeneralOptions
m
do_refocus :: RunOptions -> Bool
do_refocus :: RunOptions -> Bool
do_refocus RunOptions
opts = Bool -> Name -> GeneralOptions -> Bool
bool_opt_default Bool
True Name
"refocus" (RunOptions -> GeneralOptions
general_opts RunOptions
opts)
turn_off_refocus :: RunOptions -> RunOptions
turn_off_refocus :: RunOptions -> RunOptions
turn_off_refocus RunOptions
opts = RunOptions
opts { general_opts :: GeneralOptions
general_opts = forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert Name
"refocus" [Char]
"false" (RunOptions -> GeneralOptions
general_opts RunOptions
opts) }
turn_on_refocus :: RunOptions -> RunOptions
turn_on_refocus :: RunOptions -> RunOptions
turn_on_refocus RunOptions
opts = RunOptions
opts { general_opts :: GeneralOptions
general_opts = forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert Name
"refocus" [Char]
"true" (RunOptions -> GeneralOptions
general_opts RunOptions
opts) }
max_restarts :: RunOptions -> Maybe Int
max_restarts :: RunOptions -> Maybe Int
max_restarts = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Read a => [Char] -> a
read forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Name
"max-restarts" forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> GeneralOptions
general_opts
random_seed :: RunOptions -> Int
random_seed :: RunOptions -> Int
random_seed = forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int
0 forall a. Read a => [Char] -> a
read forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Name
"seed" forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> GeneralOptions
general_opts
do_abrupt_terminate :: RunOptions -> Bool
do_abrupt_terminate :: RunOptions -> Bool
do_abrupt_terminate = Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> GeneralOptions -> Bool
bool_opt Name
"no-abrupt-termination" forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> GeneralOptions
general_opts
pp_full_environments :: RunOptions -> Bool
pp_full_environments :: RunOptions -> Bool
pp_full_environments = Name -> GeneralOptions -> Bool
bool_opt Name
"full-environments" forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> GeneralOptions
general_opts
show_result :: RunOptions -> Bool
show_result :: RunOptions -> Bool
show_result RunOptions
opts = if Name -> GeneralOptions -> Bool
bool_opt Name
"hide-result" (RunOptions -> GeneralOptions
general_opts RunOptions
opts)
then Bool
False
else Bool -> Bool
not (RunOptions -> Bool
interactive_mode RunOptions
opts)
show_counts :: RunOptions -> Bool
show_counts :: RunOptions -> Bool
show_counts RunOptions
opts = if Name -> GeneralOptions -> Bool
bool_opt Name
"display-steps" (RunOptions -> GeneralOptions
general_opts RunOptions
opts)
then Bool -> Bool
not (RunOptions -> Bool
interactive_mode RunOptions
opts)
else Bool
False
get_nd_sources :: RunOptions -> [SourceOfND]
get_nd_sources :: RunOptions -> [SourceOfND]
get_nd_sources = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. [a]
defaultSources ([[Char]] -> [SourceOfND]
readSources forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [a] -> [[a]]
splitOn [Char]
",") forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Name
"non-deterministic" forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> GeneralOptions
general_opts
where readSources :: [[Char]] -> [SourceOfND]
readSources [[Char]]
opts = [ SourceOfND
source
| [Char]
o <- [[Char]]
opts
, SourceOfND
source <- [SourceOfND
NDRuleSelection ..]
, [Char]
o forall a. Eq a => a -> a -> Bool
== forall a. Show a => a -> [Char]
show SourceOfND
source ]
show_mutable :: RunOptions -> [Name]
show_mutable :: RunOptions -> [Name]
show_mutable = forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (forall a b. (a -> b) -> [a] -> [b]
map [Char] -> Name
pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [a] -> [[a]]
splitOn [Char]
",") forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Name
"display-mutable-entity" forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> GeneralOptions
general_opts
hide_output :: RunOptions -> [Name]
hide_output :: RunOptions -> [Name]
hide_output = forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (forall a b. (a -> b) -> [a] -> [b]
map [Char] -> Name
pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [a] -> [[a]]
splitOn [Char]
",") forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Name
"hide-output-entity" forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> GeneralOptions
general_opts
hide_input :: RunOptions -> [Name]
hide_input :: RunOptions -> [Name]
hide_input = forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (forall a b. (a -> b) -> [a] -> [b]
map [Char] -> Name
pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [a] -> [[a]]
splitOn [Char]
",") forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Name
"hide-input-entity" forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> GeneralOptions
general_opts
hide_control :: RunOptions -> [Name]
hide_control :: RunOptions -> [Name]
hide_control = forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (forall a b. (a -> b) -> [a] -> [b]
map [Char] -> Name
pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [a] -> [[a]]
splitOn [Char]
",") forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Name
"hide-control-entity" forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> GeneralOptions
general_opts
interactive_mode :: RunOptions -> Bool
interactive_mode :: RunOptions -> Bool
interactive_mode RunOptions
opts =
forall k a. Map k a -> Bool
M.null (RunOptions -> InputValues
inputValues RunOptions
opts) Bool -> Bool -> Bool
&& Name -> GeneralOptions -> Bool
bool_opt Name
"interactive-mode" (RunOptions -> GeneralOptions
general_opts RunOptions
opts)
pp_string_outputs :: RunOptions -> Bool
pp_string_outputs :: RunOptions -> Bool
pp_string_outputs = Name -> GeneralOptions -> Bool
bool_opt Name
"format-string-outputs" forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> GeneralOptions
general_opts
string_inputs :: RunOptions -> Bool
string_inputs :: RunOptions -> Bool
string_inputs = Name -> GeneralOptions -> Bool
bool_opt Name
"string-inputs" forall b c a. (b -> c) -> (a -> b) -> a -> c
. RunOptions -> GeneralOptions
general_opts
show_tests :: RunOptions -> Bool
show_tests :: RunOptions -> Bool
show_tests RunOptions
opts = if Name -> GeneralOptions -> Bool
bool_opt Name
"hide-tests" (RunOptions -> GeneralOptions
general_opts RunOptions
opts)
then Bool
False
else forall k a. Map k a -> Int
M.size (RunOptions -> TestOptions
expected_outcomes RunOptions
opts) forall a. Ord a => a -> a -> Bool
> Int
0
show_output_only :: RunOptions -> Bool
show_output_only :: RunOptions -> Bool
show_output_only RunOptions
opts = if Name -> GeneralOptions -> Bool
bool_opt Name
"show-output-only" (RunOptions -> GeneralOptions
general_opts RunOptions
opts)
then Bool
True
else RunOptions -> Bool
interactive_mode RunOptions
opts
auto_config :: RunOptions -> Bool
auto_config :: RunOptions -> Bool
auto_config RunOptions
opts = Bool -> Name -> GeneralOptions -> Bool
bool_opt_default Bool
True Name
"auto-config" (RunOptions -> GeneralOptions
general_opts RunOptions
opts)
csv_output :: RunOptions -> Bool
csv_output :: RunOptions -> Bool
csv_output RunOptions
opts = if Name -> GeneralOptions -> Bool
bool_opt Name
"csv" (RunOptions -> GeneralOptions
general_opts RunOptions
opts)
then Bool
True
else RunOptions -> Bool
csv_output_with_keys RunOptions
opts
csv_output_with_keys :: RunOptions -> Bool
csv_output_with_keys :: RunOptions -> Bool
csv_output_with_keys RunOptions
opts = Name -> GeneralOptions -> Bool
bool_opt Name
"csv-keys" (RunOptions -> GeneralOptions
general_opts RunOptions
opts)
inputValues :: RunOptions -> InputValues
inputValues :: RunOptions -> InputValues
inputValues = RunOptions -> InputValues
given_inputs
booleanOptions :: [[Char]]
booleanOptions =
[[Char]
"refocus", [Char]
"full-environments", [Char]
"hide-result", [Char]
"display-steps"
,[Char]
"no-abrupt-termination", [Char]
"interactive-mode", [Char]
"string-inputs"
,[Char]
"format-string-outputs", [Char]
"hide-tests", [Char]
"show-output-only"
,[Char]
"auto-config", [Char]
"csv", [Char]
"csv-keys"]
booleanOptions_ :: [[Char]]
booleanOptions_ = forall a b. (a -> b) -> [a] -> [b]
map ([Char]
"--" forall a. [a] -> [a] -> [a]
++) [[Char]]
booleanOptions
stringOptions :: [[Char]]
stringOptions = [[Char]
"display-mutable-entity", [Char]
"hide-output-entity"
, [Char]
"hide-control-entity", [Char]
"hide-input-entity", [Char]
"max-restarts"
, [Char]
"seed", [Char]
"non-deterministic"]
stringOptions_ :: [[Char]]
stringOptions_ = forall a b. (a -> b) -> [a] -> [b]
map ([Char]
"--" forall a. [a] -> [a] -> [a]
++) [[Char]]
stringOptions
allOptions :: [[Char]]
allOptions = [Char]
"funcon-term" forall a. a -> [a] -> [a]
: [[Char]]
booleanOptions forall a. [a] -> [a] -> [a]
++ [[Char]]
stringOptions
allOptions_ :: [[Char]]
allOptions_ = [Char]
"--funcon-term" forall a. a -> [a] -> [a]
: [[Char]]
booleanOptions_ forall a. [a] -> [a] -> [a]
++ [[Char]]
stringOptions_
run_options :: [String] -> IO (RunOptions, [String])
run_options :: [[Char]] -> IO (RunOptions, [[Char]])
run_options = (RunOptions, [[Char]]) -> [[Char]] -> IO (RunOptions, [[Char]])
fold (RunOptions
defaultRunOptions, [])
where fold :: (RunOptions, [[Char]]) -> [[Char]] -> IO (RunOptions, [[Char]])
fold (RunOptions
opts,[[Char]]
errors) ([Char]
arg:[[Char]]
args)
| [Char]
arg forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [[Char]]
booleanOptions_ =
let ([Char]
val, [[Char]]
rest)
| Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[Char]]
args)
, Bool -> Bool
not (forall a. Eq a => [a] -> [a] -> Bool
isPrefixOf [Char]
"--" (forall a. [a] -> a
head [[Char]]
args)) = (forall a. [a] -> a
head [[Char]]
args, forall a. [a] -> [a]
tail [[Char]]
args)
| Bool
otherwise = ([Char]
"true", [[Char]]
args)
opts' :: RunOptions
opts' = RunOptions
opts {general_opts :: GeneralOptions
general_opts = forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert ([Char] -> Name
pack (forall a. [a] -> [a]
tail (forall a. [a] -> [a]
tail [Char]
arg)))
[Char]
val (RunOptions -> GeneralOptions
general_opts RunOptions
opts)}
in (RunOptions, [[Char]]) -> [[Char]] -> IO (RunOptions, [[Char]])
fold (RunOptions
opts',[[Char]]
errors) [[Char]]
rest
| [Char]
arg forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [[Char]]
stringOptions_ Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => t a -> Int
length [[Char]]
args forall a. Ord a => a -> a -> Bool
> Int
0 =
let opts' :: RunOptions
opts' = RunOptions
opts {general_opts :: GeneralOptions
general_opts = forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert ([Char] -> Name
pack (forall a. [a] -> [a]
tail (forall a. [a] -> [a]
tail [Char]
arg)))
(forall a. [a] -> a
head [[Char]]
args) (RunOptions -> GeneralOptions
general_opts RunOptions
opts)}
in (RunOptions, [[Char]]) -> [[Char]] -> IO (RunOptions, [[Char]])
fold (RunOptions
opts', [[Char]]
errors) (forall a. [a] -> [a]
tail [[Char]]
args)
| [Char]
arg forall a. Eq a => a -> a -> Bool
== [Char]
"--funcon-term" Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => t a -> Int
length [[Char]]
args forall a. Ord a => a -> a -> Bool
> Int
0 =
let opts' :: RunOptions
opts' = RunOptions
opts {mfuncon_term :: Maybe Funcons
mfuncon_term = forall a. a -> Maybe a
Just ([Char] -> Funcons
fct_parse (forall a. [a] -> a
head [[Char]]
args))}
in (RunOptions, [[Char]]) -> [[Char]] -> IO (RunOptions, [[Char]])
fold (RunOptions
opts', [[Char]]
errors) (forall a. [a] -> [a]
tail [[Char]]
args)
| forall a. Eq a => [a] -> [a] -> Bool
isSuffixOf [Char]
".fct" [Char]
arg = do
[Char]
fct <- [Char] -> IO [Char]
readFile [Char]
arg
let cfg_name :: [Char]
cfg_name = forall a. Int -> [a] -> [a]
take (forall (t :: * -> *) a. Foldable t => t a -> Int
length [Char]
arg forall a. Num a => a -> a -> a
- Int
4) [Char]
arg forall a. [a] -> [a] -> [a]
++ [Char]
".config"
Bool
exists <- [Char] -> IO Bool
doesFileExist [Char]
cfg_name
RunOptions
opts' <- if Bool
exists Bool -> Bool -> Bool
&& RunOptions -> Bool
auto_config RunOptions
opts
then [Char] -> IO [Char]
readFile [Char]
cfg_name forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> b -> a -> c
flip ([Char] -> [Char] -> RunOptions -> RunOptions
parseAndApplyConfig [Char]
cfg_name) RunOptions
opts
else forall (m :: * -> *) a. Monad m => a -> m a
return RunOptions
opts
let opts'' :: RunOptions
opts'' = RunOptions
opts' {mfuncon_term :: Maybe Funcons
mfuncon_term = forall a. a -> Maybe a
Just ([Char] -> Funcons
fct_parse [Char]
fct)}
(RunOptions, [[Char]]) -> [[Char]] -> IO (RunOptions, [[Char]])
fold (RunOptions
opts'', [[Char]]
errors) [[Char]]
args
| forall a. Eq a => [a] -> [a] -> Bool
isSuffixOf [Char]
".config" [Char]
arg = (RunOptions, [[Char]]) -> [[Char]] -> IO (RunOptions, [[Char]])
fold (RunOptions
opts, [[Char]]
errors) ([Char]
"--config"forall a. a -> [a] -> [a]
:[Char]
argforall a. a -> [a] -> [a]
:[[Char]]
args)
| [Char]
arg forall a. Eq a => a -> a -> Bool
== [Char]
"--config" Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => t a -> Int
length [[Char]]
args forall a. Ord a => a -> a -> Bool
> Int
0 = do
let cfg_name :: [Char]
cfg_name = forall a. [a] -> a
head [[Char]]
args
Bool
exists <- [Char] -> IO Bool
doesFileExist [Char]
cfg_name
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool -> Bool
not Bool
exists) (forall a. HasCallStack => [Char] -> a
error ([Char]
"config file not found: " forall a. [a] -> [a] -> [a]
++ [Char]
cfg_name))
[Char]
str <- [Char] -> IO [Char]
readFile [Char]
cfg_name
let opts' :: RunOptions
opts' = [Char] -> [Char] -> RunOptions -> RunOptions
parseAndApplyConfig [Char]
cfg_name [Char]
str RunOptions
opts
(RunOptions, [[Char]]) -> [[Char]] -> IO (RunOptions, [[Char]])
fold (RunOptions
opts', [[Char]]
errors) (forall a. [a] -> [a]
tail [[Char]]
args)
| Bool
otherwise = do
Bool
exists <- [Char] -> IO Bool
doesFileExist ([Char]
argforall a. [a] -> [a] -> [a]
++[Char]
".fct")
if Bool
exists then (RunOptions, [[Char]]) -> [[Char]] -> IO (RunOptions, [[Char]])
fold (RunOptions
opts, [[Char]]
errors) (([Char]
argforall a. [a] -> [a] -> [a]
++[Char]
".fct")forall a. a -> [a] -> [a]
:[[Char]]
args)
else (RunOptions, [[Char]]) -> [[Char]] -> IO (RunOptions, [[Char]])
fold (RunOptions
opts, [Char]
argforall a. a -> [a] -> [a]
:[[Char]]
errors) [[Char]]
args
fold (RunOptions
opts, [[Char]]
errors) [] = forall (m :: * -> *) a. Monad m => a -> m a
return (RunOptions
opts, [[Char]]
errors)
parseAndApplyConfig :: FilePath -> String -> RunOptions -> RunOptions
parseAndApplyConfig :: [Char] -> [Char] -> RunOptions -> RunOptions
parseAndApplyConfig [Char]
fp [Char]
str = RunOptions -> RunOptions -> RunOptions
optionsOverride ([Char] -> RunOptions
config_parser [Char]
str)
config_parser :: String -> RunOptions
config_parser :: [Char] -> RunOptions
config_parser [Char]
string = case forall t (s :: * -> * -> *) a.
(Show t, Parseable t, IsSymbExpr s) =>
CombinatorOptions -> s t a -> [t] -> [a]
GLL.Combinators.parseWithOptions [CombinatorOption
maximumPivot,CombinatorOption
throwErrors] Parser RunOptions
pRunOptions
([Char] -> [Token]
Funcons.RunOptions.lexer [Char]
string) of
[] -> forall a. HasCallStack => [Char] -> a
error [Char]
"no parse (config)"
(RunOptions
c:[RunOptions]
_) -> RunOptions
c
lexer :: String -> [Token]
lexer :: [Char] -> [Token]
lexer = forall t. SubsumesToken t => LexerSettings -> [Char] -> [t]
GLL.Combinators.lexer LexerSettings
cfg_lexerSettings
cfg_lexerSettings :: LexerSettings
cfg_lexerSettings = LexerSettings
fct_lexerSettings {
keywords :: [[Char]]
keywords = (LexerSettings -> [[Char]]
keywords LexerSettings
fct_lexerSettings) forall a. [a] -> [a] -> [a]
++ [[Char]]
cfg_keywords
, keychars :: [Char]
keychars = (LexerSettings -> [Char]
keychars LexerSettings
fct_lexerSettings) forall a. [a] -> [a] -> [a]
++ [Char]
cfg_keychars
}
cfg_keychars :: [Char]
cfg_keychars = [Char]
":;="
cfg_keywords :: [[Char]]
cfg_keywords = [[Char]]
allOptions forall a. [a] -> [a] -> [a]
++ [[Char]
"result-term", [Char]
"general", [Char]
"tests", [Char]
"funcons", [Char]
"inputs"]
pRunOptions :: Parser RunOptions
pRunOptions :: Parser RunOptions
pRunOptions = [Char]
"SPECS"
forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
<:=> forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr RunOptions -> RunOptions -> RunOptions
optionsOverride RunOptions
defaultRunOptions forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$> forall t (s :: * -> * -> *) a.
(Show t, Ord t, IsSymbExpr s) =>
s t a -> SymbExpr t [a]
multiple Parser RunOptions
pSpec
pSpec :: Parser RunOptions
pSpec :: Parser RunOptions
pSpec = [Char]
"SPEC"
forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
<:=> forall t. SubsumesToken t => [Char] -> SymbExpr t [Char]
keyword [Char]
"general" forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t b
**> forall {t} {s :: * -> * -> *} {b}.
(Show t, Ord t, IsSymbExpr s, SubsumesToken t) =>
s t b -> BNF t b
braces Parser RunOptions
pGeneral
forall t (i :: * -> * -> *) (b :: * -> * -> *) a.
(Show t, Ord t, IsAltExpr i, HasAlts b) =>
i t a -> b t a -> AltExprs t a
<||> forall t. SubsumesToken t => [Char] -> SymbExpr t [Char]
keyword [Char]
"tests" forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t b
**> forall {t} {s :: * -> * -> *} {b}.
(Show t, Ord t, IsSymbExpr s, SubsumesToken t) =>
s t b -> BNF t b
braces Parser RunOptions
pTestOutcomes
forall t (i :: * -> * -> *) (b :: * -> * -> *) a.
(Show t, Ord t, IsAltExpr i, HasAlts b) =>
i t a -> b t a -> AltExprs t a
<||> forall t. SubsumesToken t => [Char] -> SymbExpr t [Char]
keyword [Char]
"funcons" forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t b
**> forall {t} {s :: * -> * -> *} {b}.
(Show t, Ord t, IsSymbExpr s, SubsumesToken t) =>
s t b -> BNF t b
braces Parser RunOptions
pBuiltinFuncons
forall t (i :: * -> * -> *) (b :: * -> * -> *) a.
(Show t, Ord t, IsAltExpr i, HasAlts b) =>
i t a -> b t a -> AltExprs t a
<||> forall t. SubsumesToken t => [Char] -> SymbExpr t [Char]
keyword [Char]
"inputs" forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t b
**> forall {t} {s :: * -> * -> *} {b}.
(Show t, Ord t, IsSymbExpr s, SubsumesToken t) =>
s t b -> BNF t b
braces Parser RunOptions
pInputValues
pGeneral :: Parser RunOptions
pGeneral :: Parser RunOptions
pGeneral = [Char]
"GENERAL"
forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
<:=> Maybe Funcons -> GeneralOptions -> RunOptions
toOpts forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$>
forall t (s :: * -> * -> *) a.
(Show t, Ord t, IsSymbExpr s) =>
s t a -> SymbExpr t (Maybe a)
optional (forall a. a -> a
id forall t (s :: * -> * -> *) b a.
(Show t, Ord t, IsSymbExpr s) =>
b -> s t a -> AltExpr t b
<$$ forall t. SubsumesToken t => [Char] -> SymbExpr t [Char]
keyword [Char]
"funcon-term" forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
':' forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
<**> Parser Funcons
pFuncons forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
';')
forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
<**> (forall k a. Ord k => [(k, a)] -> Map k a
M.fromList forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$> forall t (s :: * -> * -> *) a.
(Show t, Ord t, IsSymbExpr s) =>
s t a -> SymbExpr t [a]
multiple SymbExpr Token (Name, [Char])
pKeyValues)
where toOpts :: Maybe Funcons -> GeneralOptions -> RunOptions
toOpts Maybe Funcons
mf GeneralOptions
gen = RunOptions
defaultRunOptions {mfuncon_term :: Maybe Funcons
mfuncon_term = Maybe Funcons
mf, general_opts :: GeneralOptions
general_opts = GeneralOptions
gen}
pKeyValues :: SymbExpr Token (Name, [Char])
pKeyValues = [Char]
"GENERAL-KEYVALUES" forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
<:=> SymbExpr Token (Name, [Char])
pBoolOpts forall t (i :: * -> * -> *) (b :: * -> * -> *) a.
(Show t, Ord t, IsAltExpr i, HasAlts b) =>
i t a -> b t a -> AltExprs t a
<||> SymbExpr Token (Name, [Char])
pStringOpts
where pBoolOpts :: SymbExpr Token (Name, [Char])
pBoolOpts = [Char]
"GENERAL-BOOLS" forall {t} {f :: * -> *} {j :: * -> * -> *} {a}.
(Show t, Ord t, HasAlts (OO f j)) =>
[Char] -> f (j t a) -> SymbExpr t a
`chooses` (forall a b. (a -> b) -> [a] -> [b]
map [Char] -> AltExpr Token (Name, [Char])
pKeyValue [[Char]]
booleanOptions)
where pKeyValue :: [Char] -> AltExpr Token (Name, [Char])
pKeyValue [Char]
key = ([Char] -> Name
pack [Char]
key,) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall b a. b -> (a -> b) -> Maybe a -> b
maybe [Char]
"true" forall a. a -> a
id
forall t (s :: * -> * -> *) b a.
(Show t, Ord t, IsSymbExpr s) =>
b -> s t a -> AltExpr t b
<$$ forall t. SubsumesToken t => [Char] -> SymbExpr t [Char]
keyword [Char]
key forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
<**> forall t (s :: * -> * -> *) a.
(Show t, Ord t, IsSymbExpr s) =>
s t a -> SymbExpr t (Maybe a)
optional (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
':' forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t b
**> Parser [Char]
pBool)
forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
';'
pStringOpts :: SymbExpr Token (Name, [Char])
pStringOpts = [Char]
"GENERAL-STRINGS" forall {t} {f :: * -> *} {j :: * -> * -> *} {a}.
(Show t, Ord t, HasAlts (OO f j)) =>
[Char] -> f (j t a) -> SymbExpr t a
`chooses` (forall a b. (a -> b) -> [a] -> [b]
map [Char] -> AltExpr Token (Name, [Char])
pKeyValue [[Char]]
stringOptions)
where pKeyValue :: [Char] -> AltExpr Token (Name, [Char])
pKeyValue [Char]
key = ([Char] -> Name
pack [Char]
key,) forall t (s :: * -> * -> *) b a.
(Show t, Ord t, IsSymbExpr s) =>
b -> s t a -> AltExpr t b
<$$ forall t. SubsumesToken t => [Char] -> SymbExpr t [Char]
keyword [Char]
key forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
':'
forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
<**> Parser [Char]
pStringValue forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
';'
chooses :: [Char] -> f (j t a) -> SymbExpr t a
chooses [Char]
p f (j t a)
alts = forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
(<::=>) [Char]
p (forall (f :: * -> *) (j :: * -> * -> *) a b.
f (j a b) -> OO f j a b
OO f (j t a)
alts)
pBool :: Parser String
pBool :: Parser [Char]
pBool = [Char]
"BOOL-VALUE" forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
<:=> forall t. SubsumesToken t => SymbExpr t [Char]
id_lit
pStringValue :: Parser String
pStringValue :: Parser [Char]
pStringValue = [Char]
"STRING-VALUE" forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
<:=> forall t. SubsumesToken t => SymbExpr t [Char]
id_lit forall t (i :: * -> * -> *) (b :: * -> * -> *) a.
(Show t, Ord t, IsAltExpr i, HasAlts b) =>
i t a -> b t a -> AltExprs t a
<||> forall t. SubsumesToken t => SymbExpr t [Char]
string_lit forall t (i :: * -> * -> *) (b :: * -> * -> *) a.
(Show t, Ord t, IsAltExpr i, HasAlts b) =>
i t a -> b t a -> AltExprs t a
<||> (forall a. Show a => a -> [Char]
show forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$> forall t. SubsumesToken t => SymbExpr t Int
int_lit)
pFunconName :: Parser String
pFunconName :: Parser [Char]
pFunconName = [Char]
"FUNCON-NAME" forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
<:=> forall t. SubsumesToken t => SymbExpr t [Char]
id_lit
pTestOutcomes :: Parser RunOptions
pTestOutcomes :: Parser RunOptions
pTestOutcomes = [Char]
"TEST-OUTCOMES"
forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
<:=> TestOptions -> RunOptions
toOptions forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$> (forall k a. Ord k => Map k a -> Map k a -> Map k a
M.union forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$> AltExpr Token TestOptions
pResult forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
<**> SymbExpr Token TestOptions
pEntityValues)
where pResult :: AltExpr Token TestOptions
pResult = forall {k} {a}. IsString k => Maybe a -> Map k a
mStoreResult forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$>
forall t (s :: * -> * -> *) a.
(Show t, Ord t, IsSymbExpr s) =>
s t a -> SymbExpr t (Maybe a)
optional (forall a. a -> a
id forall t (s :: * -> * -> *) b a.
(Show t, Ord t, IsSymbExpr s) =>
b -> s t a -> AltExpr t b
<$$ forall t. SubsumesToken t => [Char] -> SymbExpr t [Char]
keyword [Char]
"result-term" forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
':'
forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
<**> Parser [Funcons]
pFunconsSeq forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
';')
where mStoreResult :: Maybe a -> Map k a
mStoreResult Maybe a
Nothing = forall k a. Map k a
M.empty
mStoreResult (Just a
f) = forall k a. k -> a -> Map k a
M.singleton k
"result-term" a
f
pEntityValues :: SymbExpr Token TestOptions
pEntityValues = [Char]
"TEST-ENTITIES" forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
<:=> forall k a. Ord k => [(k, a)] -> Map k a
M.fromList forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$> forall t (s :: * -> * -> *) a.
(Show t, Ord t, IsSymbExpr s) =>
s t a -> SymbExpr t [a]
multiple
((,) forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Name
pack forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$> Parser [Char]
pFunconName forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
':' forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
<**> Parser [Funcons]
pFunconsSeq forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
';')
toOptions :: TestOptions -> RunOptions
toOptions TestOptions
map = RunOptions
defaultRunOptions { expected_outcomes :: TestOptions
expected_outcomes = TestOptions
map }
pBuiltinFuncons :: Parser RunOptions
pBuiltinFuncons :: Parser RunOptions
pBuiltinFuncons = [Char]
"BUILTIN-FUNCONS"
forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
<:=> [(Name, Funcons)] -> RunOptions
insertFuncons forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$> forall t (s :: * -> * -> *) a.
(Show t, Ord t, IsSymbExpr s) =>
s t a -> SymbExpr t [a]
multiple ((,) forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Name
pack forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$> Parser [Char]
pFunconName forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
'='
forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
<**> Parser Funcons
pFuncons forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
';')
where insertFuncons :: [(Name, Funcons)] -> RunOptions
insertFuncons [(Name, Funcons)]
list = RunOptions
defaultRunOptions {builtin_funcons :: BuiltinFunconsOptions
builtin_funcons = forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [(Name, Funcons)]
list}
pInputValues :: Parser RunOptions
pInputValues :: Parser RunOptions
pInputValues = [Char]
"INPUT-VALUES"
forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
[Char] -> b t a -> SymbExpr t a
<:=> [(Name, [Values])] -> RunOptions
insertInputs forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$> forall t (s :: * -> * -> *) a.
(Show t, Ord t, IsSymbExpr s) =>
s t a -> SymbExpr t [a]
multiple ([Char] -> [Funcons] -> (Name, [Values])
toPair forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
<$$> Parser [Char]
pFunconName forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
':'
forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
<**> Parser [Funcons]
pFunconsSeq forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t a -> s t b -> AltExpr t a
<** forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
';')
where insertInputs :: [(Name, [Values])] -> RunOptions
insertInputs [(Name, [Values])]
list = RunOptions
defaultRunOptions { given_inputs :: InputValues
given_inputs = forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [(Name, [Values])]
list }
toPair :: [Char] -> [Funcons] -> (Name, [Values])
toPair [Char]
nm [Funcons]
fs = case forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence (forall a b. (a -> b) -> [a] -> [b]
map Funcons -> Maybe Values
recursiveFunconValue [Funcons]
fs) of
Just [Values]
vs -> ([Char] -> Name
pack [Char]
nm, [Values]
vs)
Maybe [Values]
_ -> forall a. HasCallStack => [Char] -> a
error ([Char]
"inputs for " forall a. [a] -> [a] -> [a]
++ [Char]
nm forall a. [a] -> [a] -> [a]
++ [Char]
" not a sequence of values")