1
0
forked from GitHub/gf-core

fill in more gaps in the API

This commit is contained in:
krangelov
2021-08-27 15:05:42 +02:00
parent 3e7d80bf30
commit e9ec4cef67
3 changed files with 21 additions and 1 deletions

View File

@@ -7,7 +7,7 @@ module PGF ( PGF2.PGF, readPGF
, functions, functionsByCat , functions, functionsByCat
, PGF2.Expr(..), PGF2.Literal(..), Tree , PGF2.Expr(..), PGF2.Literal(..), Tree
, PGF2.readExpr , PGF2.readExpr, PGF2.showExpr
, PGF2.mkAbs, PGF2.unAbs , PGF2.mkAbs, PGF2.unAbs
, PGF2.mkApp, PGF2.unApp, PGF2.unapply , PGF2.mkApp, PGF2.unApp, PGF2.unapply
, PGF2.mkStr, PGF2.unStr , PGF2.mkStr, PGF2.unStr
@@ -15,8 +15,10 @@ module PGF ( PGF2.PGF, readPGF
, PGF2.mkDouble, PGF2.unDouble , PGF2.mkDouble, PGF2.unDouble
, PGF2.mkFloat, PGF2.unFloat , PGF2.mkFloat, PGF2.unFloat
, PGF2.mkMeta, PGF2.unMeta , PGF2.mkMeta, PGF2.unMeta
, PGF2.exprSize, PGF2.exprFunctions
, PGF2.Type(..), PGF2.Hypo , PGF2.Type(..), PGF2.Hypo
, PGF2.readType, PGF2.showType
, PGF2.mkType, PGF2.unType , PGF2.mkType, PGF2.unType
, PGF2.mkHypo, PGF2.mkDepHypo, PGF2.mkImplHypo , PGF2.mkHypo, PGF2.mkDepHypo, PGF2.mkImplHypo

View File

@@ -32,6 +32,8 @@ module PGF2 (-- * PGF
mkDouble, unDouble, mkDouble, unDouble,
mkFloat, unFloat, mkFloat, unFloat,
mkMeta, unMeta, mkMeta, unMeta,
-- extra
exprSize, exprFunctions,
-- ** Types -- ** Types
Type(..), Hypo, BindType(..), startCat, Type(..), Hypo, BindType(..), startCat,
readType, showType, readType, showType,

View File

@@ -11,6 +11,8 @@ module PGF2.Expr(Var, Cat, Fun,
mkFloat, unFloat, mkFloat, unFloat,
mkMeta, unMeta, mkMeta, unMeta,
exprSize, exprFunctions,
mkType, unType, mkType, unType,
mkHypo, mkDepHypo, mkImplHypo mkHypo, mkDepHypo, mkImplHypo
@@ -152,6 +154,20 @@ unMeta (ETyped e ty) = unMeta e
unMeta (EImplArg e) = unMeta e unMeta (EImplArg e) = unMeta e
unMeta _ = Nothing 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 -- | creates a type from list of hypothesises, category and
-- list of arguments for the category. The operation -- list of arguments for the category. The operation