summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-04-20 22:29:36 +0200
committerPéter Diviánszky <divipp@gmail.com>2016-04-20 22:29:36 +0200
commit71e72247060237b4de5d5b8f4035505f90384028 (patch)
treef26cffa90d4370111c20708ab7c71bb7181a0543 /src
parent142b97cfad651e4759a55fbca9da8ad862e349da (diff)
Freq appear
Diffstat (limited to 'src')
-rw-r--r--src/LambdaCube/Compiler/Infer.hs41
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 @@
17module LambdaCube.Compiler.Infer 17module 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
54data Exp 54data 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
64data Freq = CompileTime | RunTime
65 deriving (Eq, Show)
66
67pattern TType = TType_ CompileTime
68
64pattern ELit a <- (unfixlabel -> ELit_ a) where ELit = ELit_ 69pattern ELit a <- (unfixlabel -> ELit_ a) where ELit = ELit_
65 70
66data Neutral 71data Neutral
@@ -248,15 +253,15 @@ pattern TTyCon0 s <- (unfixlabel -> TyCon (TyConName s _ TType _ _) [])
248tTyCon0 s cs = Closed $ TyCon (TyConName s 0 TType (map ((,) (error "tTyCon0")) cs) $ CaseFunName (error "TTyCon0-A") (error "TTyCon0-B") 0) [] 253tTyCon0 s cs = Closed $ TyCon (TyConName s 0 TType (map ((,) (error "tTyCon0")) cs) $ CaseFunName (error "TTyCon0-A") (error "TTyCon0-B") 0) []
249pattern a :~> b = Pi Visible a b 254pattern a :~> b = Pi Visible a b
250 255
251pattern Unit <- TTyCon0 FUnit where Unit = tTyCon0 FUnit [Unit] 256pattern Unit <- TTyCon0 FUnit where Unit = tTyCon0 FUnit [Unit]
252pattern TInt <- TTyCon0 FInt where TInt = tTyCon0 FInt $ error "cs 1" 257pattern TInt <- TTyCon0 FInt where TInt = tTyCon0 FInt $ error "cs 1"
253pattern TNat <- TTyCon0 FNat where TNat = tTyCon0 FNat $ error "cs 3" 258pattern TNat <- TTyCon0 FNat where TNat = tTyCon0 FNat $ error "cs 3"
254pattern TBool <- TTyCon0 FBool where TBool = tTyCon0 FBool $ error "cs 4" 259pattern TBool <- TTyCon0 FBool where TBool = tTyCon0 FBool $ error "cs 4"
255pattern TFloat <- TTyCon0 FFloat where TFloat = tTyCon0 FFloat $ error "cs 5" 260pattern TFloat <- TTyCon0 FFloat where TFloat = tTyCon0 FFloat $ error "cs 5"
256pattern TString <- TTyCon0 FString where TString = tTyCon0 FString $ error "cs 6" 261pattern TString <- TTyCon0 FString where TString = tTyCon0 FString $ error "cs 6"
257pattern TChar <- TTyCon0 FChar where TChar = tTyCon0 FChar $ error "cs 7" 262pattern TChar <- TTyCon0 FChar where TChar = tTyCon0 FChar $ error "cs 7"
258pattern TOrdering <- TTyCon0 FOrdering where TOrdering = tTyCon0 FOrdering $ error "cs 8" 263pattern TOrdering <- TTyCon0 FOrdering where TOrdering = tTyCon0 FOrdering $ error "cs 8"
259pattern TVec a b <- TyConN FVecS {-(TType :~> TNat :~> TType)-} [b, a] 264pattern TVec a b <- TyConN FVecS [b, a]
260 265
261pattern Empty s <- TyCon (TyConName FEmpty _ _ _ _) [EString s] where 266pattern 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 [])
265pattern Zero <- ConN FZero _ where Zero = Closed (tCon FZero 0 TNat []) 270pattern Zero <- ConN FZero _ where Zero = Closed (tCon FZero 0 TNat [])
266pattern Succ n <- ConN FSucc (n:_) where Succ n = tCon FSucc 1 (TNat :~> TNat) [n] 271pattern Succ n <- ConN FSucc (n:_) where Succ n = tCon FSucc 1 (TNat :~> TNat) [n]
267 272
268pattern CstrT t a b = Neut (CstrT' t a b) 273pattern CstrT t a b = Neut (CstrT' t a b)
269pattern CstrT' t a b = TFun' FEqCT (TType :~> Var 0 :~> Var 1 :~> TType) [t, a, b] 274pattern CstrT' t a b = TFun' FEqCT (TType :~> Var 0 :~> Var 1 :~> TType) [t, a, b]
270pattern Coe a b w x = TFun Fcoe (TType :~> TType :~> CstrT TType (Var 1) (Var 0) :~> Var 2 :~> Var 2) [a,b,w,x] 275pattern Coe a b w x = TFun Fcoe (TType :~> TType :~> CstrT TType (Var 1) (Var 0) :~> Var 2 :~> Var 2) [a,b,w,x]
271pattern ParEval t a b = TFun FparEval (TType :~> Var 0 :~> Var 1 :~> Var 2) [t, a, b] 276pattern ParEval t a b = TFun FparEval (TType :~> Var 0 :~> Var 1 :~> Var 2) [t, a, b]
272pattern T2 a b = TFun FT2 (TType :~> TType :~> TType) [a, b] 277pattern T2 a b = TFun FT2 (TType :~> TType :~> TType) [a, b]
273pattern CSplit a b c <- UFunN FSplit [a, b, c] 278pattern CSplit a b c <- UFunN FSplit [a, b, c]
274 279
275pattern EInt a = ELit (LInt a) 280pattern EInt a = ELit (LInt a)
276pattern EFloat a = ELit (LFloat a) 281pattern 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