summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2010-07-31 16:40:16 +0000
committerkrasimir <krasimir@chalmers.se>2010-07-31 16:40:16 +0000
commit94bd76df7219fcc9a530782dedfa0566cde1d8d6 (patch)
tree9a08371475cb762d4cfc6a160977066707f0f645
parent98c22ef92b14491fd36dc3545f07ab62f92f6e02 (diff)
two new functions in the PGF API: mkAbs, unAbs
-rw-r--r--src/runtime/haskell/PGF.hs1
-rw-r--r--src/runtime/haskell/PGF/Expr.hs10
2 files changed, 11 insertions, 0 deletions
diff --git a/src/runtime/haskell/PGF.hs b/src/runtime/haskell/PGF.hs
index 652399f69..9bdfd8b23 100644
--- a/src/runtime/haskell/PGF.hs
+++ b/src/runtime/haskell/PGF.hs
@@ -43,6 +43,7 @@ module PGF(
-- ** Expr
Expr,
showExpr, readExpr,
+ mkAbs, unAbs,
mkApp, unApp,
mkStr, unStr,
mkInt, unInt,
diff --git a/src/runtime/haskell/PGF/Expr.hs b/src/runtime/haskell/PGF/Expr.hs
index 2202a20c4..554726815 100644
--- a/src/runtime/haskell/PGF/Expr.hs
+++ b/src/runtime/haskell/PGF/Expr.hs
@@ -1,6 +1,7 @@
module PGF.Expr(Tree, BindType(..), Expr(..), Literal(..), Patt(..), Equation(..),
readExpr, showExpr, pExpr, pBinds, ppExpr, ppPatt, pattScope,
+ mkAbs, unAbs,
mkApp, unApp,
mkStr, unStr,
mkInt, unInt,
@@ -96,6 +97,15 @@ showExpr vars = PP.render . ppExpr 0 vars
instance Read Expr where
readsPrec _ = RP.readP_to_S pExpr
+mkAbs :: BindType -> CId -> Expr -> Expr
+mkAbs = EAbs
+
+unAbs :: Expr -> Maybe (BindType, CId, Expr)
+unAbs (EAbs bt x e) = Just (bt,x,e)
+unAbs (ETyped e ty) = unAbs e
+unAbs (EImplArg e) = unAbs e
+unAbs _ = Nothing
+
-- | Constructs an expression by applying a function to a list of expressions
mkApp :: CId -> [Expr] -> Expr
mkApp f es = foldl EApp (EFun f) es