diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2012-09-18 09:48:21 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2012-09-18 09:48:21 +0000 |
| commit | fe3b5c1360c3c3b062d471dd9273b90b24a3d4ab (patch) | |
| tree | ae051746e93187720f8f986f594fc8e2ff050f44 /src | |
| parent | a307ed6c75c2dbf116170f0dc1904e6725ac74f3 (diff) | |
the Haskell runtime now exports 'functionsByCat' which returns the list of all functions for a given category
Diffstat (limited to 'src')
| -rw-r--r-- | src/runtime/haskell/PGF.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/runtime/haskell/PGF.hs b/src/runtime/haskell/PGF.hs index b03349963..010c9a7ef 100644 --- a/src/runtime/haskell/PGF.hs +++ b/src/runtime/haskell/PGF.hs @@ -35,7 +35,7 @@ module PGF( categories, startCat, -- * Functions - functions, functionType, + functions, functionsByCat, functionType, -- * Expressions & Trees -- ** Tree @@ -227,6 +227,9 @@ startCat :: PGF -> Type -- | List of all functions defined in the abstract syntax functions :: PGF -> [CId] +-- | List of all functions defined for a given category +functionsByCat :: PGF -> CId -> [CId] + -- | The type of a given function functionType :: PGF -> CId -> Maybe Type @@ -276,6 +279,11 @@ startCat pgf = DTyp [] (lookStartCat 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 = case Map.lookup fun (funs (abstract pgf)) of Just (ty,_,_,_,_) -> Just ty |
