diff --git a/src/runtime/haskell/PGF.hs b/src/runtime/haskell/PGF.hs index b439ef45f..7e685d71a 100644 --- a/src/runtime/haskell/PGF.hs +++ b/src/runtime/haskell/PGF.hs @@ -7,7 +7,7 @@ module PGF ( PGF2.PGF, readPGF , functions, functionsByCat , PGF2.Expr(..), PGF2.Literal(..), Tree - , PGF2.readExpr + , PGF2.readExpr, PGF2.showExpr , PGF2.mkAbs, PGF2.unAbs , PGF2.mkApp, PGF2.unApp, PGF2.unapply , PGF2.mkStr, PGF2.unStr @@ -15,8 +15,10 @@ module PGF ( PGF2.PGF, readPGF , PGF2.mkDouble, PGF2.unDouble , PGF2.mkFloat, PGF2.unFloat , PGF2.mkMeta, PGF2.unMeta + , PGF2.exprSize, PGF2.exprFunctions , PGF2.Type(..), PGF2.Hypo + , PGF2.readType, PGF2.showType , PGF2.mkType, PGF2.unType , PGF2.mkHypo, PGF2.mkDepHypo, PGF2.mkImplHypo diff --git a/src/runtime/haskell/PGF2.hsc b/src/runtime/haskell/PGF2.hsc index 2654948e7..a59cf37cd 100644 --- a/src/runtime/haskell/PGF2.hsc +++ b/src/runtime/haskell/PGF2.hsc @@ -32,6 +32,8 @@ module PGF2 (-- * PGF mkDouble, unDouble, mkFloat, unFloat, mkMeta, unMeta, + -- extra + exprSize, exprFunctions, -- ** Types Type(..), Hypo, BindType(..), startCat, readType, showType, diff --git a/src/runtime/haskell/PGF2/Expr.hs b/src/runtime/haskell/PGF2/Expr.hs index b2a4db8bc..a8b4abe73 100644 --- a/src/runtime/haskell/PGF2/Expr.hs +++ b/src/runtime/haskell/PGF2/Expr.hs @@ -11,6 +11,8 @@ module PGF2.Expr(Var, Cat, Fun, mkFloat, unFloat, mkMeta, unMeta, + exprSize, exprFunctions, + mkType, unType, mkHypo, mkDepHypo, mkImplHypo @@ -152,6 +154,20 @@ unMeta (ETyped e ty) = unMeta e unMeta (EImplArg e) = unMeta e unMeta _ = Nothing +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 -> [Fun] +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 _ = [] -- | creates a type from list of hypothesises, category and -- list of arguments for the category. The operation