module Test.OITestGenerator.OpArg (
OpArg(), opArg,
opArg_name, opArg_argi, opArg_gens, opArg_has_constraint, opArg_constraint,
op2opArgs
) where
import Data.Label
import Data.Maybe
import Language.Haskell.TH
import Prelude
import Test.OITestGenerator.Op
data OpArg = OpArg {
_name :: Name,
_argi :: Int,
_gens :: [Name],
_constraint :: Maybe Name
}
mkLabel ''OpArg
opArg :: Name -> Int -> [Name] -> Maybe Name -> OpArg
opArg name' argi' gens' constraint' = OpArg {
_name = name',
_argi = argi',
_gens = gens',
_constraint = constraint'
}
op2opArg :: Op -> Int -> Q OpArg
op2opArg opn argi' = do
gens' <- op_gens opn
return $ opArg (op_name opn) argi' gens' (op_maybe_constraint opn)
op2opArgs :: Op -> Q [OpArg]
op2opArgs opn = op_args opn >>= mapM (op2opArg opn)
opArg_name :: OpArg -> Name
opArg_name = get name
opArg_argi :: OpArg -> Int
opArg_argi = get argi
opArg_gens :: OpArg -> [Name]
opArg_gens = get gens
opArg_has_constraint :: OpArg -> Bool
opArg_has_constraint = isJust . get constraint
opArg_constraint :: OpArg -> Name
opArg_constraint = fromJust . get constraint