diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-04-20 22:29:36 +0200 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-04-20 22:29:36 +0200 |
commit | 71e72247060237b4de5d5b8f4035505f90384028 (patch) | |
tree | f26cffa90d4370111c20708ab7c71bb7181a0543 /src | |
parent | 142b97cfad651e4759a55fbca9da8ad862e349da (diff) |
Freq appear
Diffstat (limited to 'src')
-rw-r--r-- | src/LambdaCube/Compiler/Infer.hs | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/LambdaCube/Compiler/Infer.hs b/src/LambdaCube/Compiler/Infer.hs index 40b77f9e..66fef1a8 100644 --- a/src/LambdaCube/Compiler/Infer.hs +++ b/src/LambdaCube/Compiler/Infer.hs | |||
@@ -17,7 +17,7 @@ | |||
17 | module LambdaCube.Compiler.Infer | 17 | module LambdaCube.Compiler.Infer |
18 | ( SName, Lit(..), Visibility(..) | 18 | ( SName, Lit(..), Visibility(..) |
19 | , Exp (..), Neutral (..), ExpType, GlobalEnv | 19 | , Exp (..), Neutral (..), ExpType, GlobalEnv |
20 | , pattern Var, pattern CaseFun, pattern TyCaseFun, pattern App_, app_ | 20 | , pattern Var, pattern CaseFun, pattern TyCaseFun, pattern App_, app_, pattern TType |
21 | , pattern Con, pattern TyCon, pattern Pi, pattern Lam, pattern Fun, pattern ELit, pattern Func, pattern LabelEnd, pattern FL, pattern UFL, unFunc_ | 21 | , pattern Con, pattern TyCon, pattern Pi, pattern Lam, pattern Fun, pattern ELit, pattern Func, pattern LabelEnd, pattern FL, pattern UFL, unFunc_ |
22 | , outputType, boolType, trueExp | 22 | , outputType, boolType, trueExp |
23 | , down, Subst (..), free, subst, upDB | 23 | , down, Subst (..), free, subst, upDB |
@@ -52,7 +52,7 @@ import LambdaCube.Compiler.Parser | |||
52 | -------------------------------------------------------------------------------- core expression representation | 52 | -------------------------------------------------------------------------------- core expression representation |
53 | 53 | ||
54 | data Exp | 54 | data Exp |
55 | = TType | 55 | = TType_ Freq |
56 | | ELit_ Lit | 56 | | ELit_ Lit |
57 | | Con_ !MaxDB ConName !Int{-number of ereased arguments applied-} [Exp] | 57 | | Con_ !MaxDB ConName !Int{-number of ereased arguments applied-} [Exp] |
58 | | TyCon_ !MaxDB TyConName [Exp] | 58 | | TyCon_ !MaxDB TyConName [Exp] |
@@ -61,6 +61,11 @@ data Exp | |||
61 | | Neut Neutral | 61 | | Neut Neutral |
62 | deriving (Show) | 62 | deriving (Show) |
63 | 63 | ||
64 | data Freq = CompileTime | RunTime | ||
65 | deriving (Eq, Show) | ||
66 | |||
67 | pattern TType = TType_ CompileTime | ||
68 | |||
64 | pattern ELit a <- (unfixlabel -> ELit_ a) where ELit = ELit_ | 69 | pattern ELit a <- (unfixlabel -> ELit_ a) where ELit = ELit_ |
65 | 70 | ||
66 | data Neutral | 71 | data Neutral |
@@ -248,15 +253,15 @@ pattern TTyCon0 s <- (unfixlabel -> TyCon (TyConName s _ TType _ _) []) | |||
248 | tTyCon0 s cs = Closed $ TyCon (TyConName s 0 TType (map ((,) (error "tTyCon0")) cs) $ CaseFunName (error "TTyCon0-A") (error "TTyCon0-B") 0) [] | 253 | tTyCon0 s cs = Closed $ TyCon (TyConName s 0 TType (map ((,) (error "tTyCon0")) cs) $ CaseFunName (error "TTyCon0-A") (error "TTyCon0-B") 0) [] |
249 | pattern a :~> b = Pi Visible a b | 254 | pattern a :~> b = Pi Visible a b |
250 | 255 | ||
251 | pattern Unit <- TTyCon0 FUnit where Unit = tTyCon0 FUnit [Unit] | 256 | pattern Unit <- TTyCon0 FUnit where Unit = tTyCon0 FUnit [Unit] |
252 | pattern TInt <- TTyCon0 FInt where TInt = tTyCon0 FInt $ error "cs 1" | 257 | pattern TInt <- TTyCon0 FInt where TInt = tTyCon0 FInt $ error "cs 1" |
253 | pattern TNat <- TTyCon0 FNat where TNat = tTyCon0 FNat $ error "cs 3" | 258 | pattern TNat <- TTyCon0 FNat where TNat = tTyCon0 FNat $ error "cs 3" |
254 | pattern TBool <- TTyCon0 FBool where TBool = tTyCon0 FBool $ error "cs 4" | 259 | pattern TBool <- TTyCon0 FBool where TBool = tTyCon0 FBool $ error "cs 4" |
255 | pattern TFloat <- TTyCon0 FFloat where TFloat = tTyCon0 FFloat $ error "cs 5" | 260 | pattern TFloat <- TTyCon0 FFloat where TFloat = tTyCon0 FFloat $ error "cs 5" |
256 | pattern TString <- TTyCon0 FString where TString = tTyCon0 FString $ error "cs 6" | 261 | pattern TString <- TTyCon0 FString where TString = tTyCon0 FString $ error "cs 6" |
257 | pattern TChar <- TTyCon0 FChar where TChar = tTyCon0 FChar $ error "cs 7" | 262 | pattern TChar <- TTyCon0 FChar where TChar = tTyCon0 FChar $ error "cs 7" |
258 | pattern TOrdering <- TTyCon0 FOrdering where TOrdering = tTyCon0 FOrdering $ error "cs 8" | 263 | pattern TOrdering <- TTyCon0 FOrdering where TOrdering = tTyCon0 FOrdering $ error "cs 8" |
259 | pattern TVec a b <- TyConN FVecS {-(TType :~> TNat :~> TType)-} [b, a] | 264 | pattern TVec a b <- TyConN FVecS [b, a] |
260 | 265 | ||
261 | pattern Empty s <- TyCon (TyConName FEmpty _ _ _ _) [EString s] where | 266 | pattern Empty s <- TyCon (TyConName FEmpty _ _ _ _) [EString s] where |
262 | Empty s = TyCon (TyConName FEmpty (error "todo: inum2_") (TString :~> TType) (error "todo: tcn cons 3_") $ error "Empty") [EString s] | 267 | Empty s = TyCon (TyConName FEmpty (error "todo: inum2_") (TString :~> TType) (error "todo: tcn cons 3_") $ error "Empty") [EString s] |
@@ -265,12 +270,12 @@ pattern TT <- ConN' _ _ where TT = Closed (tCon FTT 0 Unit []) | |||
265 | pattern Zero <- ConN FZero _ where Zero = Closed (tCon FZero 0 TNat []) | 270 | pattern Zero <- ConN FZero _ where Zero = Closed (tCon FZero 0 TNat []) |
266 | pattern Succ n <- ConN FSucc (n:_) where Succ n = tCon FSucc 1 (TNat :~> TNat) [n] | 271 | pattern Succ n <- ConN FSucc (n:_) where Succ n = tCon FSucc 1 (TNat :~> TNat) [n] |
267 | 272 | ||
268 | pattern CstrT t a b = Neut (CstrT' t a b) | 273 | pattern CstrT t a b = Neut (CstrT' t a b) |
269 | pattern CstrT' t a b = TFun' FEqCT (TType :~> Var 0 :~> Var 1 :~> TType) [t, a, b] | 274 | pattern CstrT' t a b = TFun' FEqCT (TType :~> Var 0 :~> Var 1 :~> TType) [t, a, b] |
270 | pattern Coe a b w x = TFun Fcoe (TType :~> TType :~> CstrT TType (Var 1) (Var 0) :~> Var 2 :~> Var 2) [a,b,w,x] | 275 | pattern Coe a b w x = TFun Fcoe (TType :~> TType :~> CstrT TType (Var 1) (Var 0) :~> Var 2 :~> Var 2) [a,b,w,x] |
271 | pattern ParEval t a b = TFun FparEval (TType :~> Var 0 :~> Var 1 :~> Var 2) [t, a, b] | 276 | pattern ParEval t a b = TFun FparEval (TType :~> Var 0 :~> Var 1 :~> Var 2) [t, a, b] |
272 | pattern T2 a b = TFun FT2 (TType :~> TType :~> TType) [a, b] | 277 | pattern T2 a b = TFun FT2 (TType :~> TType :~> TType) [a, b] |
273 | pattern CSplit a b c <- UFunN FSplit [a, b, c] | 278 | pattern CSplit a b c <- UFunN FSplit [a, b, c] |
274 | 279 | ||
275 | pattern EInt a = ELit (LInt a) | 280 | pattern EInt a = ELit (LInt a) |
276 | pattern EFloat a = ELit (LFloat a) | 281 | pattern EFloat a = ELit (LFloat a) |
@@ -380,7 +385,7 @@ instance Eq Exp where | |||
380 | Pi a b c == Pi a' b' c' = (a, b, c) == (a', b', c') | 385 | Pi a b c == Pi a' b' c' = (a, b, c) == (a', b', c') |
381 | Con a n b == Con a' n' b' = (a, n, b) == (a', n', b') | 386 | Con a n b == Con a' n' b' = (a, n, b) == (a', n', b') |
382 | TyCon a b == TyCon a' b' = (a, b) == (a', b') | 387 | TyCon a b == TyCon a' b' = (a, b) == (a', b') |
383 | TType == TType = True | 388 | TType_ f == TType_ f' = f == f' |
384 | ELit l == ELit l' = l == l' | 389 | ELit l == ELit l' = l == l' |
385 | Neut a == Neut a' = a == a' | 390 | Neut a == Neut a' = a == a' |
386 | _ == _ = False | 391 | _ == _ = False |