diff options
| author | aarne <aarne@cs.chalmers.se> | 2007-12-06 21:43:21 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2007-12-06 21:43:21 +0000 |
| commit | 64ebc4f1679b89bccb4328641a2432096e3288b6 (patch) | |
| tree | 53ee2f1b22a4e8b9f92acb256b62d753977b0daa /src/GF/Devel/Grammar/Macros.hs | |
| parent | fe30e3274872db43e96ed9db467e51f12f53effb (diff) | |
new type checker type checks
Diffstat (limited to 'src/GF/Devel/Grammar/Macros.hs')
| -rw-r--r-- | src/GF/Devel/Grammar/Macros.hs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/GF/Devel/Grammar/Macros.hs b/src/GF/Devel/Grammar/Macros.hs index 659ddb107..51c1669f4 100644 --- a/src/GF/Devel/Grammar/Macros.hs +++ b/src/GF/Devel/Grammar/Macros.hs @@ -21,11 +21,22 @@ typeForm t = (co,f,a) where (co,t2) = prodForm t (f,a) = appForm t2 +termForm :: Term -> ([Ident],Term,[Term]) +termForm t = (co,f,a) where + (co,t2) = absForm t + (f,a) = appForm t2 + prodForm :: Type -> (Context,Term) prodForm t = case t of Prod x ty val -> ((x,ty):co,t2) where (co,t2) = prodForm val _ -> ([],t) +absForm :: Term -> ([Ident],Term) +absForm t = case t of + Abs x val -> (x:co,t2) where (co,t2) = absForm val + _ -> ([],t) + + appForm :: Term -> (Term,[Term]) appForm tr = (f,reverse xs) where (f,xs) = apps tr @@ -171,6 +182,8 @@ isTypeInts ty = case ty of App c _ -> c == constPredefRes "Ints" _ -> False +cnPredef = constPredefRes + constPredefRes :: String -> Term constPredefRes s = Q (IC "Predef") (identC s) @@ -214,6 +227,15 @@ judgementOpModule f m = do return m {mjments = mjs} where fj = either (liftM Left . f) (return . Right) + +entryOpModule :: Monad m => + (Ident -> Judgement -> m Judgement) -> Module -> m Module +entryOpModule f m = do + mjs <- liftM Map.fromAscList $ mapm $ Map.assocs $ mjments m + return $ m {mjments = mjs} + where + mapm = mapM (\ (i,j) -> liftM ((,) i) (fe i j)) + fe i j = either (liftM Left . f i) (return . Right) j termOpJudgement :: Monad m => (Term -> m Term) -> Judgement -> m Judgement termOpJudgement f j = do |
