1
0
forked from GitHub/gf-core

partial evaluation for (+)

This commit is contained in:
krangelov
2021-10-05 15:37:42 +02:00
parent 93c2f47752
commit 3c4e7dd20c
3 changed files with 9 additions and 0 deletions

View File

@@ -126,6 +126,11 @@ eval env (C t1 t2) [] = do v1 <- eval env t1 []
(VC vs1,v2 ) -> return (VC (vs1++[v2]))
(v1, VC vs2) -> return (VC ([v1]++vs2))
(v1, v2 ) -> return (VC [v1,v2])
eval env t@(Glue t1 t2) [] = do v1 <- eval env t1 []
v2 <- eval env t2 []
case liftM2 (++) (value2string v1) (value2string v2) of
Just s -> return (string2value s)
Nothing -> evalError ("Cannot reduce term" <+> pp t)
eval env (FV ts) vs = msum [eval env t vs | t <- ts]
eval env (Error msg) vs = fail msg
eval env t vs = evalError ("Cannot reduce term" <+> pp t)

View File

@@ -31,3 +31,5 @@ cc "x"++SOFT_BIND++"y"
cc "x"++SOFT_SPACE++"y"
cc "x"++CAPIT++"y"
cc "x"++ALL_CAPIT++"y"
cc "a"+"b"
cc eqInt (length ("a"+"b")) 2

View File

@@ -32,3 +32,5 @@ CallStack (from HasCallStack):
"x" ++ Predef.SOFT_SPACE ++ "y"
"x" ++ Predef.CAPIT ++ "y"
"x" ++ Predef.ALL_CAPIT ++ "y"
"ab"
Predef.PTrue