summaryrefslogtreecommitdiff
path: root/src/Test.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Test.hs')
-rw-r--r--src/Test.hs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Test.hs b/src/Test.hs
index 16c1b1f..7b9be6f 100644
--- a/src/Test.hs
+++ b/src/Test.hs
@@ -96,6 +96,7 @@ data Expr a where
Literal :: ExprType a => a -> Expr a
Concat :: [Expr Text] -> Expr Text
Regex :: [Expr Text] -> Expr Regex
+ UnOp :: (b -> a) -> Expr b -> Expr a
BinOp :: (b -> c -> a) -> Expr b -> Expr c -> Expr a
eval :: MonadEval m => Expr a -> m a
@@ -114,6 +115,7 @@ eval (Regex xs) = do
case compile defaultCompOpt defaultExecOpt $ T.concat $ concat [[T.singleton '^'], parts, [T.singleton '$']] of
Left err -> fail err
Right re -> return re
+eval (UnOp f x) = f <$> eval x
eval (BinOp f x y) = f <$> eval x <*> eval y
gatherVars :: forall a m. MonadEval m => Expr a -> m [(VarName, SomeVarValue)]
@@ -124,4 +126,5 @@ gatherVars = fmap (uniqOn fst . sortOn fst) . helper
helper (Literal _) = return []
helper (Concat es) = concat <$> mapM helper es
helper (Regex es) = concat <$> mapM helper es
+ helper (UnOp _ e) = helper e
helper (BinOp _ e f) = (++) <$> helper e <*> helper f