summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2010-12-06 14:19:51 +0000
committerkrasimir <krasimir@chalmers.se>2010-12-06 14:19:51 +0000
commitb6446ec36dcb537f39d38893f8cbe8c355c1b504 (patch)
treef6eababb1d764fe364f268f1a1959bc24f6b7c0a /src/runtime
parent0f444d889302b68f2b7edbe31e4ddcd37e45454a (diff)
simple refactoring in PGF.Macros and related
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/haskell/PGF/Macros.hs24
-rw-r--r--src/runtime/haskell/PGF/VisualizeTree.hs4
2 files changed, 14 insertions, 14 deletions
diff --git a/src/runtime/haskell/PGF/Macros.hs b/src/runtime/haskell/PGF/Macros.hs
index aecb584d5..31af63534 100644
--- a/src/runtime/haskell/PGF/Macros.hs
+++ b/src/runtime/haskell/PGF/Macros.hs
@@ -18,24 +18,24 @@ import Text.PrettyPrint
mapConcretes :: (Concr -> Concr) -> PGF -> PGF
mapConcretes f pgf = pgf { concretes = Map.map f (concretes pgf) }
-lookType :: PGF -> CId -> Type
-lookType pgf f =
- case lookMap (error $ "lookType " ++ show f) f (funs (abstract pgf)) of
+lookType :: Abstr -> CId -> Type
+lookType abs f =
+ case lookMap (error $ "lookType " ++ show f) f (funs abs) of
(ty,_,_,_) -> ty
-lookDef :: PGF -> CId -> Maybe [Equation]
-lookDef pgf f =
- case lookMap (error $ "lookDef " ++ show f) f (funs (abstract pgf)) of
+lookDef :: Abstr -> CId -> Maybe [Equation]
+lookDef abs f =
+ case lookMap (error $ "lookDef " ++ show f) f (funs abs) of
(_,a,eqs,_) -> eqs
-isData :: PGF -> CId -> Bool
-isData pgf f =
- case Map.lookup f (funs (abstract pgf)) of
+isData :: Abstr -> CId -> Bool
+isData abs f =
+ case Map.lookup f (funs abs) of
Just (_,_,Nothing,_) -> True -- the encoding of data constrs
_ -> False
-lookValCat :: PGF -> CId -> CId
-lookValCat pgf = valCat . lookType pgf
+lookValCat :: Abstr -> CId -> CId
+lookValCat abs = valCat . lookType abs
lookStartCat :: PGF -> CId
lookStartCat pgf = mkCId $
@@ -119,7 +119,7 @@ showPrintName :: PGF -> Language -> CId -> String
showPrintName pgf lang id = lookMap (showCId id) id $ printnames $ lookMap (error "no lang") lang $ concretes pgf
-- lookup with default value
-lookMap :: (Show i, Ord i) => a -> i -> Map.Map i a -> a
+lookMap :: Ord i => a -> i -> Map.Map i a -> a
lookMap d c m = Map.findWithDefault d c m
--- from Operations
diff --git a/src/runtime/haskell/PGF/VisualizeTree.hs b/src/runtime/haskell/PGF/VisualizeTree.hs
index c054e1e78..dfb1cbd75 100644
--- a/src/runtime/haskell/PGF/VisualizeTree.hs
+++ b/src/runtime/haskell/PGF/VisualizeTree.hs
@@ -65,7 +65,7 @@ graphvizAbstractTree pgf (funs,cats) = render . tree2graph
getApp e es = (e,es)
getLbl scope (EFun f) = let fun = if funs then ppCId f else empty
- cat = if cats then ppCId (lookValCat pgf f) else empty
+ cat = if cats then ppCId (lookValCat (abstract pgf) f) else empty
sep = if funs && cats then colon else empty
in fun <+> sep <+> cat
getLbl scope (ELit l) = text (escapeStr (render (ppLit l)))
@@ -503,7 +503,7 @@ graphvizDependencyTree format debug mlab ms pgf lang tr = case format of
wnodes = [[show i, maltws ws, showCId fun, pos, pos, morph, show dom, lab, unspec, unspec] |
(i, ((fun,p),ws)) <- tail nodeWords,
- let pos = showCId $ lookValCat pgf fun,
+ let pos = showCId $ lookValCat (abstract pgf) fun,
let morph = unspec,
let (dom,lab) = lookDomLab p
]