mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
two new functions in the PGF API: mkAbs, unAbs
This commit is contained in:
@@ -43,6 +43,7 @@ module PGF(
|
|||||||
-- ** Expr
|
-- ** Expr
|
||||||
Expr,
|
Expr,
|
||||||
showExpr, readExpr,
|
showExpr, readExpr,
|
||||||
|
mkAbs, unAbs,
|
||||||
mkApp, unApp,
|
mkApp, unApp,
|
||||||
mkStr, unStr,
|
mkStr, unStr,
|
||||||
mkInt, unInt,
|
mkInt, unInt,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
module PGF.Expr(Tree, BindType(..), Expr(..), Literal(..), Patt(..), Equation(..),
|
module PGF.Expr(Tree, BindType(..), Expr(..), Literal(..), Patt(..), Equation(..),
|
||||||
readExpr, showExpr, pExpr, pBinds, ppExpr, ppPatt, pattScope,
|
readExpr, showExpr, pExpr, pBinds, ppExpr, ppPatt, pattScope,
|
||||||
|
|
||||||
|
mkAbs, unAbs,
|
||||||
mkApp, unApp,
|
mkApp, unApp,
|
||||||
mkStr, unStr,
|
mkStr, unStr,
|
||||||
mkInt, unInt,
|
mkInt, unInt,
|
||||||
@@ -96,6 +97,15 @@ showExpr vars = PP.render . ppExpr 0 vars
|
|||||||
instance Read Expr where
|
instance Read Expr where
|
||||||
readsPrec _ = RP.readP_to_S pExpr
|
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
|
-- | Constructs an expression by applying a function to a list of expressions
|
||||||
mkApp :: CId -> [Expr] -> Expr
|
mkApp :: CId -> [Expr] -> Expr
|
||||||
mkApp f es = foldl EApp (EFun f) es
|
mkApp f es = foldl EApp (EFun f) es
|
||||||
|
|||||||
Reference in New Issue
Block a user