-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(but just the syntax, it doesn't work yet) darcs-hash:20070118112457-974a0-98e1a260b9066033df50ebddfe73140741341b79.gz
- Loading branch information
eb
committed
Jan 18, 2007
1 parent
2eccc26
commit d5e9743
Showing
9 changed files
with
164 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
> {-# OPTIONS_GHC -fglasgow-exts #-} | ||
|
||
> module Ivor.PatternDefs where | ||
|
||
> import Ivor.Gadgets | ||
> import Ivor.TTCore | ||
> import Ivor.Datatype | ||
> import Ivor.Nobby | ||
> import Ivor.Typecheck | ||
|
||
> import Debug.Trace | ||
|
||
Use the iota schemes from Datatype to represent pattern matching definitions. | ||
|
||
> type PMRaw = RawScheme | ||
> type PMDef n = Scheme n | ||
|
||
> data PMFun n = PMFun [PMDef n] | ||
> deriving Show | ||
|
||
> checkDef :: Monad m => Gamma Name -> Name -> Raw -> [PMRaw] -> m (PMFun Name) | ||
> checkDef gam n ty rschs = do | ||
> schs <- mapM (checkClause gam n ty) rschs | ||
> -- TODO: Coverage and termination checking | ||
> return $ PMFun schs | ||
|
||
> checkClause :: Monad m => Gamma Name -> Name -> Raw -> PMRaw -> | ||
> m (PMDef Name) | ||
> checkClause gam n ty sch@(RSch args ret) = trace (show sch) $ do | ||
> (argscheck, bs) <- checkArgs [] args ty | ||
> (ret, _) <- check gam bs (getrettype ty) Nothing | ||
> return $ Sch argscheck ret | ||
> where checkArgs bindings [] _ = return ([], bindings) | ||
> checkArgs bindings (x:xs) (RBind nm (B Pi t) ts) = trace (show x ++ " : " ++ show t ++ ", " ++ show bindings) $ do | ||
> (xcheck, bs) <- checkPatt gam bindings Nothing x t | ||
> (Ind tyc, _) <- check gam bs t (Just (Ind Star)) | ||
> (xscheck, bs') <- checkArgs ((nm,B Pi tyc):bs) xs ts | ||
> return (xcheck:xscheck, bs') | ||
|
||
mkEnv = map (\ (n,Ind t) -> (n, B Pi t)) | ||
|
||
|
||
|
||
checkClause gam n (RSch pats ret) = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters