summaryrefslogtreecommitdiff
path: root/src/runtime/haskell/PGF.hs
diff options
context:
space:
mode:
authorKrasimir Angelov <kr.angelov@gmail.com>2017-09-05 10:16:48 +0200
committerKrasimir Angelov <kr.angelov@gmail.com>2017-09-05 10:16:48 +0200
commit13d804581427f4d6e8ef21d440e822bf67ade434 (patch)
treeb670ecb08991fe50b0a5a9c6bd8757f595dd00e5 /src/runtime/haskell/PGF.hs
parent5ed0e3ae7f73dbbfca504f0b5af5a9b8d3a2e5f4 (diff)
added exprSize and exprFunctions in the Haskell runtime too and use them in TreeOperations
Diffstat (limited to 'src/runtime/haskell/PGF.hs')
-rw-r--r--src/runtime/haskell/PGF.hs19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/runtime/haskell/PGF.hs b/src/runtime/haskell/PGF.hs
index 42519fb63..1c425a565 100644
--- a/src/runtime/haskell/PGF.hs
+++ b/src/runtime/haskell/PGF.hs
@@ -54,7 +54,7 @@ module PGF(
mkFloat, unFloat,
mkMeta, unMeta,
-- extra
- pExpr,
+ pExpr, exprSize, exprFunctions,
-- * Operations
-- ** Linearization
@@ -314,6 +314,23 @@ functionType pgf fun =
compute :: PGF -> Expr -> Expr
compute pgf = PGF.Data.normalForm (funs (abstract pgf),const Nothing) 0 []
+exprSize :: Expr -> Int
+exprSize (EAbs _ _ e) = exprSize e
+exprSize (EApp e1 e2) = exprSize e1 + exprSize e2
+exprSize (ETyped e ty)= exprSize e
+exprSize (EImplArg e) = exprSize e
+exprSize _ = 1
+
+exprFunctions :: Expr -> [CId]
+exprFunctions (EAbs _ _ e) = exprFunctions e
+exprFunctions (EApp e1 e2) = exprFunctions e1 ++ exprFunctions e2
+exprFunctions (ETyped e ty)= exprFunctions e
+exprFunctions (EImplArg e) = exprFunctions e
+exprFunctions (EFun f) = [f]
+exprFunctions _ = []
+
+--exprFunctions :: Expr -> [Fun]
+
browse :: PGF -> CId -> Maybe (String,[CId],[CId])
browse pgf id = fmap (\def -> (def,producers,consumers)) definition
where