diff options
| author | aarne <aarne@chalmers.se> | 2013-11-05 17:28:47 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2013-11-05 17:28:47 +0000 |
| commit | aba666c5bc7a46cdc7de7e2a36869456c34909bd (patch) | |
| tree | a5b8f7a8f8ba8a7778d4bf72c388fb0a5b8853ad /src/runtime/haskell/PGF | |
| parent | 3814841d7d3b77b3f033cb98c1c0a04ac39435d7 (diff) | |
linearization by chunks in the GF shell: a new command 'lc' needed because 'l' requires type checking and trees with metavariable function heads don't type check. This will hopefully be a temporary command.
Diffstat (limited to 'src/runtime/haskell/PGF')
| -rw-r--r-- | src/runtime/haskell/PGF/Expr.hs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/runtime/haskell/PGF/Expr.hs b/src/runtime/haskell/PGF/Expr.hs index 01b791847..264be4aaa 100644 --- a/src/runtime/haskell/PGF/Expr.hs +++ b/src/runtime/haskell/PGF/Expr.hs @@ -2,7 +2,7 @@ module PGF.Expr(Tree, BindType(..), Expr(..), Literal(..), Patt(..), Equation(.. readExpr, showExpr, pExpr, pBinds, ppExpr, ppPatt, pattScope,
mkAbs, unAbs,
- mkApp, unApp,
+ mkApp, unApp, unAppForm,
mkStr, unStr,
mkInt, unInt,
mkDouble, unDouble,
@@ -112,13 +112,19 @@ mkApp f es = foldl EApp (EFun f) es -- | Decomposes an expression into application of function
unApp :: Expr -> Maybe (CId,[Expr])
-unApp = extract []
+unApp e = case unAppForm e of
+ (EFun f,es) -> Just (f,es)
+ _ -> Nothing
+
+-- | Decomposes an expression into an application of a constructor such as a constant or a metavariable
+unAppForm :: Expr -> (Expr,[Expr])
+unAppForm = extract []
where
- extract es (EFun f) = Just (f,es)
+ extract es f@(EFun _) = (f,es)
extract es (EApp e1 e2) = extract (e2:es) e1
extract es (ETyped e ty)= extract es e
extract es (EImplArg e) = extract es e
- extract es _ = Nothing
+ extract es h = (h,es)
-- | Constructs an expression from string literal
mkStr :: String -> Expr
|
