mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
the Haskell runtime now exports 'functionsByCat' which returns the list of all functions for a given category
This commit is contained in:
@@ -35,7 +35,7 @@ module PGF(
|
|||||||
categories, startCat,
|
categories, startCat,
|
||||||
|
|
||||||
-- * Functions
|
-- * Functions
|
||||||
functions, functionType,
|
functions, functionsByCat, functionType,
|
||||||
|
|
||||||
-- * Expressions & Trees
|
-- * Expressions & Trees
|
||||||
-- ** Tree
|
-- ** Tree
|
||||||
@@ -227,6 +227,9 @@ startCat :: PGF -> Type
|
|||||||
-- | List of all functions defined in the abstract syntax
|
-- | List of all functions defined in the abstract syntax
|
||||||
functions :: PGF -> [CId]
|
functions :: PGF -> [CId]
|
||||||
|
|
||||||
|
-- | List of all functions defined for a given category
|
||||||
|
functionsByCat :: PGF -> CId -> [CId]
|
||||||
|
|
||||||
-- | The type of a given function
|
-- | The type of a given function
|
||||||
functionType :: PGF -> CId -> Maybe Type
|
functionType :: PGF -> CId -> Maybe Type
|
||||||
|
|
||||||
@@ -276,6 +279,11 @@ startCat pgf = DTyp [] (lookStartCat pgf) []
|
|||||||
|
|
||||||
functions pgf = Map.keys (funs (abstract pgf))
|
functions pgf = Map.keys (funs (abstract pgf))
|
||||||
|
|
||||||
|
functionsByCat pgf cat =
|
||||||
|
case Map.lookup cat (cats (abstract pgf)) of
|
||||||
|
Just (_,fns,_) -> map snd fns
|
||||||
|
Nothing -> []
|
||||||
|
|
||||||
functionType pgf fun =
|
functionType pgf fun =
|
||||||
case Map.lookup fun (funs (abstract pgf)) of
|
case Map.lookup fun (funs (abstract pgf)) of
|
||||||
Just (ty,_,_,_,_) -> Just ty
|
Just (ty,_,_,_,_) -> Just ty
|
||||||
|
|||||||
Reference in New Issue
Block a user