summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO7
-rw-r--r--lc/Builtins.lc6
-rw-r--r--src/LambdaCube/Compiler/CoreToIR.hs3
-rw-r--r--src/LambdaCube/Compiler/Infer.hs126
-rw-r--r--testdata/Builtins.out126
-rw-r--r--testdata/Prelude.out36
-rw-r--r--testdata/complex.out16
7 files changed, 169 insertions, 151 deletions
diff --git a/TODO b/TODO
index f676e203..2992a1a7 100644
--- a/TODO
+++ b/TODO
@@ -69,6 +69,11 @@ done:
69 69
700.5 goal: improvement + linear time interpretation 700.5 goal: improvement + linear time interpretation
71 71
72done:
73- compiler: (~) :: forall a . a -> a -> Type
74
75next:
76
72- blog about release: 77- blog about release:
73 - few sentences about the past events 78 - few sentences about the past events
74 - this is the 2nd version (first rewrite) of the DSL using the learnings from the first one 79 - this is the 2nd version (first rewrite) of the DSL using the learnings from the first one
@@ -89,7 +94,6 @@ done:
89- docs: feature teaser, 2 min paper videos 94- docs: feature teaser, 2 min paper videos
90- testenv: performance benchmarks 95- testenv: performance benchmarks
91 96
92- compiler: (~) :: forall a b . a -> b -> Type
93- compiler: ConName --> Int 97- compiler: ConName --> Int
94- compiler: support let labels 98- compiler: support let labels
95- compiler optimization: irrelevance + erasure 99- compiler optimization: irrelevance + erasure
@@ -159,6 +163,7 @@ extra (refactoring):
159- community: blog about compiler internals 163- community: blog about compiler internals
160- backend: generated backends 164- backend: generated backends
161- user supplied cpu values like color values and rendering context 165- user supplied cpu values like color values and rendering context
166- compiler: (~) :: forall a b . a -> b -> Type ?
162- compiler: add more structure to witnesses? 167- compiler: add more structure to witnesses?
163- review all old disabled test cases 168- review all old disabled test cases
164- 100% test coverage of the parser 169- 100% test coverage of the parser
diff --git a/lc/Builtins.lc b/lc/Builtins.lc
index 77027a39..d4226f25 100644
--- a/lc/Builtins.lc
+++ b/lc/Builtins.lc
@@ -462,7 +462,7 @@ PrimBShiftL, PrimBShiftR :: (Integral t, a ~ VecScalar d t, b ~ VecScalar d
462PrimBShiftLS, PrimBShiftRS :: (Integral t, a ~ VecScalar d t) => a -> Word -> a 462PrimBShiftLS, PrimBShiftRS :: (Integral t, a ~ VecScalar d t) => a -> Word -> a
463-- Logic Functions 463-- Logic Functions
464PrimAnd, PrimOr, PrimXor :: Bool -> Bool -> Bool 464PrimAnd, PrimOr, PrimXor :: Bool -> Bool -> Bool
465PrimNot :: (a ~ VecScalar d Bool) => a -> a 465PrimNot :: forall a d . (a ~ VecScalar d Bool) => a -> a
466PrimAny, PrimAll :: VecScalar d Bool -> Bool 466PrimAny, PrimAll :: VecScalar d Bool -> Bool
467 467
468-- Angle, Trigonometry and Exponential Functions 468-- Angle, Trigonometry and Exponential Functions
@@ -509,8 +509,8 @@ PrimMulVecMat :: Vec h a -> Mat h w a -> Vec w a
509PrimMulMatMat :: Mat i j a -> Mat j k a -> Mat i k a 509PrimMulMatMat :: Mat i j a -> Mat j k a -> Mat i k a
510-- Vector and Scalar Relational Functions 510-- Vector and Scalar Relational Functions
511PrimLessThan, PrimLessThanEqual, PrimGreaterThan, PrimGreaterThanEqual, PrimEqualV, PrimNotEqualV 511PrimLessThan, PrimLessThanEqual, PrimGreaterThan, PrimGreaterThanEqual, PrimEqualV, PrimNotEqualV
512 :: (Num t, a ~ VecScalar d t, b ~ VecScalar d Bool) => a -> a -> b 512 :: forall a d t b . (Num t, a ~ VecScalar d t, b ~ VecScalar d Bool) => a -> a -> b
513PrimEqual, PrimNotEqual :: (t ~ MatVecScalarElem a) => a -> a -> Bool 513PrimEqual, PrimNotEqual :: forall a t . (t ~ MatVecScalarElem a) => a -> a -> Bool
514-- Fragment Processing Functions 514-- Fragment Processing Functions
515PrimDFdx, PrimDFdy, PrimFWidth 515PrimDFdx, PrimDFdy, PrimFWidth
516 :: (a ~ VecScalar d Float) => a -> a 516 :: (a ~ VecScalar d Float) => a -> a
diff --git a/src/LambdaCube/Compiler/CoreToIR.hs b/src/LambdaCube/Compiler/CoreToIR.hs
index 293b1bc9..04ce6ed1 100644
--- a/src/LambdaCube/Compiler/CoreToIR.hs
+++ b/src/LambdaCube/Compiler/CoreToIR.hs
@@ -892,7 +892,8 @@ toExp = flip runReader [] . flip evalStateT freshTypeVars . f_
892 I.Pi b x yt -> newName >>= \n -> do 892 I.Pi b x yt -> newName >>= \n -> do
893 t <- f_ (x, I.TType) 893 t <- f_ (x, I.TType)
894 Lam b (PVar t n) t <$> local ((Var n t, x):) (f_ (y, yt)) 894 Lam b (PVar t n) t <$> local ((Var n t, x):) (f_ (y, yt))
895 I.Con s n xs -> Con (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) (I.mkConPars n et ++ xs) 895 I.Con s n xs -> Con (show s) <$> f_ (t, I.TType) <*> chain [] t (I.mkConPars n et ++ xs)
896 where t = I.conType et s
896 I.TyCon s xs -> Con (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) xs 897 I.TyCon s xs -> Con (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) xs
897 I.Fun s xs -> Fun (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) xs 898 I.Fun s xs -> Fun (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) xs
898 I.CaseFun s xs n -> asks makeTE >>= \te -> Fun (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) (I.makeCaseFunPars te n ++ xs ++ [I.Neut n]) 899 I.CaseFun s xs n -> asks makeTE >>= \te -> Fun (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) (I.makeCaseFunPars te n ++ xs ++ [I.Neut n])
diff --git a/src/LambdaCube/Compiler/Infer.hs b/src/LambdaCube/Compiler/Infer.hs
index ae2a9f1b..21ffe022 100644
--- a/src/LambdaCube/Compiler/Infer.hs
+++ b/src/LambdaCube/Compiler/Infer.hs
@@ -26,7 +26,7 @@ module LambdaCube.Compiler.Infer
26 , Infos(..), listInfos, ErrorMsg(..), PolyEnv(..), ErrorT, throwErrorTCM, parseLC, joinPolyEnvs, filterPolyEnv, inference_ 26 , Infos(..), listInfos, ErrorMsg(..), PolyEnv(..), ErrorT, throwErrorTCM, parseLC, joinPolyEnvs, filterPolyEnv, inference_
27 , ImportItems (..) 27 , ImportItems (..)
28 , SI(..), Range(..) 28 , SI(..), Range(..)
29 , nType, neutType, appTy, mkConPars, makeCaseFunPars, unpmlabel 29 , nType, conType, neutType, appTy, mkConPars, makeCaseFunPars, unpmlabel
30 , MaxDB(..) 30 , MaxDB(..)
31 ) where 31 ) where
32import Data.Monoid 32import Data.Monoid
@@ -69,9 +69,9 @@ data Neutral
69 | PMLabel_ FunName !Int [Exp] Exp{-unfolded expression-} 69 | PMLabel_ FunName !Int [Exp] Exp{-unfolded expression-}
70 deriving (Show) 70 deriving (Show)
71 71
72data ConName = ConName SName MFixity Int{-ordinal number, e.g. Zero:0, Succ:1-} TyConName Type 72data ConName = ConName SName MFixity Int{-ordinal number, e.g. Zero:0, Succ:1-} Type
73 73
74data TyConName = TyConName SName MFixity Int{-num of indices-} Type [ConName]{-constructors-} CaseFunName 74data TyConName = TyConName SName MFixity Int{-num of indices-} Type [(ConName, Type)]{-constructors-} CaseFunName
75 75
76data FunName = FunName_ SName ([Exp] -> Exp) MFixity Type 76data FunName = FunName_ SName ([Exp] -> Exp) MFixity Type
77pattern FunName a b c <- FunName_ a _ b c where FunName a b c = funName a b c 77pattern FunName a b c <- FunName_ a _ b c where FunName a b c = funName a b c
@@ -86,8 +86,8 @@ type Type = Exp
86type ExpType = (Exp, Type) 86type ExpType = (Exp, Type)
87type SExp2 = SExp' ExpType 87type SExp2 = SExp' ExpType
88 88
89instance Show ConName where show (ConName n _ _ _ _) = n 89instance Show ConName where show (ConName n _ _ _) = n
90instance Eq ConName where ConName _ _ n _ _ == ConName _ _ n' _ _ = n == n' 90instance Eq ConName where ConName _ _ n _ == ConName _ _ n' _ = n == n'
91instance Show TyConName where show (TyConName n _ _ _ _ _) = n 91instance Show TyConName where show (TyConName n _ _ _ _ _) = n
92instance Eq TyConName where TyConName n _ _ _ _ _ == TyConName n' _ _ _ _ _ = n == n' 92instance Eq TyConName where TyConName n _ _ _ _ _ == TyConName n' _ _ _ _ _ = n == n'
93instance Show FunName where show (FunName n _ _) = n 93instance Show FunName where show (FunName n _ _) = n
@@ -115,9 +115,7 @@ pattern Var a = Neut (Var_ a)
115conParams (conTypeName -> TyConName _ _ _ _ _ (CaseFunName _ _ pars)) = pars 115conParams (conTypeName -> TyConName _ _ _ _ _ (CaseFunName _ _ pars)) = pars
116mkConPars n (snd . getParams -> TyCon (TyConName _ _ _ _ _ (CaseFunName _ _ pars)) xs) = take (min n pars) xs 116mkConPars n (snd . getParams -> TyCon (TyConName _ _ _ _ _ (CaseFunName _ _ pars)) xs) = take (min n pars) xs
117mkConPars n x = error $ "mkConPars: " ++ ppShow x 117mkConPars n x = error $ "mkConPars: " ++ ppShow x
118conName a b c d = ConName a b c (get $ snd $ getParams d) d 118conName = ConName
119 where
120 get (TyCon s _) = s
121 119
122makeCaseFunPars te n = case neutType te n of 120makeCaseFunPars te n = case neutType te n of
123 TyCon (TyConName _ _ _ _ _ (CaseFunName _ _ pars)) xs -> take pars xs 121 TyCon (TyConName _ _ _ _ _ (CaseFunName _ _ pars)) xs -> take pars xs
@@ -126,7 +124,8 @@ pattern Closed :: () => Up a => a -> a
126pattern Closed a <- a where Closed a = closedExp a 124pattern Closed a <- a where Closed a = closedExp a
127 125
128pattern Con x n y <- Con_ _ x n y where Con x n y = Con_ (foldMap maxDB_ y) x n y 126pattern Con x n y <- Con_ _ x n y where Con x n y = Con_ (foldMap maxDB_ y) x n y
129pattern ConN s a <- Con (ConName s _ _ _ _) _ a 127pattern ConN s a <- Con (ConName s _ _ _) _ a
128pattern ConN' s a <- Con (ConName _ _ s _) _ a
130tCon s i t a = Con (conName s Nothing i t) 0 a 129tCon s i t a = Con (conName s Nothing i t) 0 a
131tCon_ k s i t a = Con (conName s Nothing i t) k a 130tCon_ k s i t a = Con (conName s Nothing i t) k a
132pattern TyCon x y <- TyCon_ _ x y where TyCon x y = TyCon_ (foldMap maxDB_ y) x y 131pattern TyCon x y <- TyCon_ _ x y where TyCon x y = TyCon_ (foldMap maxDB_ y) x y
@@ -136,26 +135,31 @@ pattern FunN a b <- Fun (FunName a _ _) b
136pattern TFun a t b <- Fun (FunName a _ t) b where TFun a t b = Fun (FunName a Nothing t) b 135pattern TFun a t b <- Fun (FunName a _ t) b where TFun a t b = Fun (FunName a Nothing t) b
137pattern TFun' a t b <- Fun_ (FunName a _ t) b where TFun' a t b = Fun_ (FunName a Nothing t) b 136pattern TFun' a t b <- Fun_ (FunName a _ t) b where TFun' a t b = Fun_ (FunName a Nothing t) b
138pattern TyConN s a <- TyCon (TyConName s _ _ _ _ _) a 137pattern TyConN s a <- TyCon (TyConName s _ _ _ _ _) a
139pattern TTyCon s t a <- TyCon (TyConName s _ _ t _ _) a where TTyCon s t a = TyCon (TyConName s Nothing (error "todo: inum") t (error "todo: tcn cons 2") $ CaseFunName (error "TTyCon-A") (error "TTyCon-B") $ length a) a 138pattern TTyCon s t a <- TyCon (TyConName s _ _ t _ _) a
140pattern TTyCon0 s <- TyCon (TyConName s _ _ TType _ _) [] where TTyCon0 s = Closed $ TyCon (TyConName s Nothing 0 TType (error "todo: tcn cons 3") $ CaseFunName (error "TTyCon0-A") (error "TTyCon0-B") 0) [] 139tTyCon s t a cs = TyCon (TyConName s Nothing (error "todo: inum") t (map ((,) (error "tTyCon")) cs) $ CaseFunName (error "TTyCon-A") (error "TTyCon-B") $ length a) a
140pattern TTyCon0 s <- TyCon (TyConName s _ _ TType _ _) []
141tTyCon0 s cs = Closed $ TyCon (TyConName s Nothing 0 TType (map ((,) (error "tTyCon0")) cs) $ CaseFunName (error "TTyCon0-A") (error "TTyCon0-B") 0) []
141pattern a :~> b = Pi Visible a b 142pattern a :~> b = Pi Visible a b
142 143
143pattern Unit = TTyCon0 "'Unit" 144pattern Unit <- TTyCon0 "'Unit" where Unit = tTyCon0 "'Unit" [Unit]
144pattern TInt = TTyCon0 "'Int" 145pattern TInt <- TTyCon0 "'Int" where TInt = tTyCon0 "'Int" $ error "cs 1"
145pattern TImageSemantics = TTyCon0 "'ImageSemantics" 146pattern TImageSemantics <- TTyCon0 "'ImageSemantics" where TImageSemantics = tTyCon0 "'ImageSemantics" $ error "cs 2"
146pattern TNat = TTyCon0 "'Nat" 147pattern TNat <- TTyCon0 "'Nat" where TNat = tTyCon0 "'Nat" $ error "cs 3"
147pattern TBool = TTyCon0 "'Bool" 148pattern TBool <- TTyCon0 "'Bool" where TBool = tTyCon0 "'Bool" $ error "cs 4"
148pattern TFloat = TTyCon0 "'Float" 149pattern TFloat <- TTyCon0 "'Float" where TFloat = tTyCon0 "'Float" $ error "cs 5"
149pattern TString = TTyCon0 "'String" 150pattern TString <- TTyCon0 "'String" where TString = tTyCon0 "'String" $ error "cs 6"
150pattern TChar = TTyCon0 "'Char" 151pattern TChar <- TTyCon0 "'Char" where TChar = tTyCon0 "'Char" $ error "cs 7"
151pattern TOrdering = TTyCon0 "'Ordering" 152pattern TOrdering <- TTyCon0 "'Ordering" where TOrdering = tTyCon0 "'Ordering" $ error "cs 8"
152pattern TTuple2 a b = TTyCon "'Tuple2" (TType :~> TType :~> TType) [a, b] 153pattern TOutput <- TTyCon0 "'Output" where TOutput = tTyCon0 "'Output" $ error "cs 9"
153pattern TVec a b <- TyConN "'VecS" {-(TType :~> TNat :~> TType)-} [b, a] 154pattern TTuple0 <- TTyCon0 "'Tuple0" where TTuple0 = tTyCon0 "'Tuple0" $ error "cs 10"
154pattern TList a = TTyCon "'List" (TType :~> TType) [a] 155pattern TVec a b <- TyConN "'VecS" {-(TType :~> TNat :~> TType)-} [b, a]
156--pattern TTuple2 a b = TTyCon "'Tuple2" (TType :~> TType :~> TType) [a, b]
157pattern TList a <- TyConN "'List" [a] where TList a = tTyCon "'List" (TType :~> TType) [a] $ error "cs 11"
158pattern TInterpolated x <- TyConN "'Interpolated" [x] where TInterpolated x = tTyCon "'Interpolated" (TType :~> TType) [x] $ error "cs 12"
155pattern Empty s <- TyCon (TyConName "'Empty" _ _ _ _ _) [EString s] where 159pattern Empty s <- TyCon (TyConName "'Empty" _ _ _ _ _) [EString s] where
156 Empty s = TyCon (TyConName "'Empty" Nothing (error "todo: inum2_") (TString :~> TType) (error "todo: tcn cons 3_") $ error "Empty") [EString s] 160 Empty s = TyCon (TyConName "'Empty" Nothing (error "todo: inum2_") (TString :~> TType) (error "todo: tcn cons 3_") $ error "Empty") [EString s]
157 161
158pattern TT <- ConN "TT" _ where TT = Closed (tCon "TT" 0 Unit []) 162pattern TT <- ConN' _ _ where TT = Closed (tCon "TT" 0 Unit [])
159nil = (tCon_ 1 "Nil" 0 (Pi Hidden TType $ TList (Var 0)) []) 163nil = (tCon_ 1 "Nil" 0 (Pi Hidden TType $ TList (Var 0)) [])
160cons a b = (tCon_ 1 "Cons" 1 (Pi Hidden TType $ Var 0 :~> TList (Var 1) :~> TList (Var 2)) [a, b]) 164cons a b = (tCon_ 1 "Cons" 1 (Pi Hidden TType $ Var 0 :~> TList (Var 1) :~> TList (Var 2)) [a, b])
161pattern Zero <- ConN "Zero" _ where Zero = Closed (tCon "Zero" 0 TNat []) 165pattern Zero <- ConN "Zero" _ where Zero = Closed (tCon "Zero" 0 TNat [])
@@ -177,6 +181,7 @@ pattern EChar a = ELit (LChar a)
177pattern EString a = ELit (LString a) 181pattern EString a = ELit (LString a)
178pattern EBool a <- (getEBool -> Just a) where EBool = mkBool 182pattern EBool a <- (getEBool -> Just a) where EBool = mkBool
179pattern ENat n <- (fromNatE -> Just n) where ENat = toNatE 183pattern ENat n <- (fromNatE -> Just n) where ENat = toNatE
184pattern ENat' n <- (fromNatE' -> Just n)
180 185
181pattern NoTup <- (noTup -> True) 186pattern NoTup <- (noTup -> True)
182 187
@@ -191,19 +196,24 @@ pattern NoTup <- (noTup -> True)
191--tTuple3 a b c = TTyCon "'Tuple3" (TType :~> TType :~> TType :~> TType) [a, b, c] 196--tTuple3 a b c = TTyCon "'Tuple3" (TType :~> TType :~> TType :~> TType) [a, b, c]
192 197
193toNatE :: Int -> Exp 198toNatE :: Int -> Exp
194toNatE 0 = Closed Zero 199toNatE 0 = Zero
195toNatE n | n > 0 = Closed (Succ (toNatE (n - 1))) 200toNatE n | n > 0 = Closed (Succ (toNatE (n - 1)))
196 201
197fromNatE :: Exp -> Maybe Int 202fromNatE :: Exp -> Maybe Int
198fromNatE Zero = Just 0 203fromNatE (ConN' 0 _) = Just 0
199fromNatE (Succ n) = (1 +) <$> fromNatE n 204fromNatE (ConN' 1 [n]) = (1 +) <$> fromNatE n
200fromNatE _ = Nothing 205fromNatE _ = Nothing
201 206
207fromNatE' :: Exp -> Maybe Int
208fromNatE' Zero = Just 0
209fromNatE' (Succ n) = (1 +) <$> fromNatE' n
210fromNatE' _ = Nothing
211
202mkBool False = Closed $ tCon "False" 0 TBool [] 212mkBool False = Closed $ tCon "False" 0 TBool []
203mkBool True = Closed $ tCon "True" 1 TBool [] 213mkBool True = Closed $ tCon "True" 1 TBool []
204 214
205getEBool (ConN "False" _) = Just False 215getEBool (ConN' 0 _) = Just False
206getEBool (ConN "True" _) = Just True 216getEBool (ConN' 1 _) = Just True
207getEBool _ = Nothing 217getEBool _ = Nothing
208 218
209mkOrdering x = Closed $ case x of 219mkOrdering x = Closed $ case x of
@@ -215,9 +225,9 @@ noTup (TyConN s _) = take 6 s /= "'Tuple" -- todo
215noTup _ = False 225noTup _ = False
216 226
217conTypeName :: ConName -> TyConName 227conTypeName :: ConName -> TyConName
218conTypeName (ConName _ _ _ t _) = t 228conTypeName (ConName _ _ _ t) = case snd $ getParams t of TyCon n _ -> n
219 229
220outputType = TTyCon0 "'Output" 230outputType = TOutput
221boolType = TBool 231boolType = TBool
222trueExp = EBool True 232trueExp = EBool True
223 233
@@ -427,7 +437,7 @@ varType err n_ env = f n_ env where
427 f n e = either (error $ "varType: " ++ err ++ "\n" ++ show n_ ++ "\n" ++ ppShow env) (f n) $ parent e 437 f n e = either (error $ "varType: " ++ err ++ "\n" ++ show n_ ++ "\n" ++ ppShow env) (f n) $ parent e
428 438
429-------------------------------------------------------------------------------- reduction 439-------------------------------------------------------------------------------- reduction
430evalCaseFun a ps (Con n@(ConName _ _ i _ _) _ vs) 440evalCaseFun a ps (Con n@(ConName _ _ i _) _ vs)
431 | i /= (-1) = foldl app_ (ps !!! (i + 1)) vs 441 | i /= (-1) = foldl app_ (ps !!! (i + 1)) vs
432 | otherwise = error "evcf" 442 | otherwise = error "evcf"
433 where 443 where
@@ -485,14 +495,14 @@ getFunDef s = case show s of
485 "primCompareString" -> \case [EString x, EString y] -> mkOrdering $ x `compare` y; xs -> f xs 495 "primCompareString" -> \case [EString x, EString y] -> mkOrdering $ x `compare` y; xs -> f xs
486 496
487 -- LambdaCube 3D specific primitives 497 -- LambdaCube 3D specific primitives
488 "PrimGreaterThan" -> \case [_, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (>) x y -> r; xs -> f xs 498 "PrimGreaterThan" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (>) t x y -> r; xs -> f xs
489 "PrimGreaterThanEqual" -> \case [_, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (>=) x y -> r; xs -> f xs 499 "PrimGreaterThanEqual" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (>=) t x y -> r; xs -> f xs
490 "PrimLessThan" -> \case [_, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (<) x y -> r; xs -> f xs 500 "PrimLessThan" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (<) t x y -> r; xs -> f xs
491 "PrimLessThanEqual" -> \case [_, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (<=) x y -> r; xs -> f xs 501 "PrimLessThanEqual" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (<=) t x y -> r; xs -> f xs
492 "PrimEqualV" -> \case [_, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (==) x y -> r; xs -> f xs 502 "PrimEqualV" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (==) t x y -> r; xs -> f xs
493 "PrimNotEqualV" -> \case [_, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (/=) x y -> r; xs -> f xs 503 "PrimNotEqualV" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (/=) t x y -> r; xs -> f xs
494 "PrimEqual" -> \case [_, _, _, x, y] | Just r <- twoOpBool (==) x y -> r; xs -> f xs 504 "PrimEqual" -> \case [t, _, _, x, y] | Just r <- twoOpBool (==) t x y -> r; xs -> f xs
495 "PrimNotEqual" -> \case [_, _, _, x, y] | Just r <- twoOpBool (/=) x y -> r; xs -> f xs 505 "PrimNotEqual" -> \case [t, _, _, x, y] | Just r <- twoOpBool (/=) t x y -> r; xs -> f xs
496 "PrimSubS" -> \case [_, _, _, _, x, y] | Just r <- twoOp (-) x y -> r; xs -> f xs 506 "PrimSubS" -> \case [_, _, _, _, x, y] | Just r <- twoOp (-) x y -> r; xs -> f xs
497 "PrimSub" -> \case [_, _, x, y] | Just r <- twoOp (-) x y -> r; xs -> f xs 507 "PrimSub" -> \case [_, _, x, y] | Just r <- twoOp (-) x y -> r; xs -> f xs
498 "PrimAddS" -> \case [_, _, _, _, x, y] | Just r <- twoOp (+) x y -> r; xs -> f xs 508 "PrimAddS" -> \case [_, _, _, _, x, y] | Just r <- twoOp (+) x y -> r; xs -> f xs
@@ -507,7 +517,7 @@ getFunDef s = case show s of
507 "PrimAnd" -> \case [EBool x, EBool y] -> EBool (x && y); xs -> f xs 517 "PrimAnd" -> \case [EBool x, EBool y] -> EBool (x && y); xs -> f xs
508 "PrimOr" -> \case [EBool x, EBool y] -> EBool (x || y); xs -> f xs 518 "PrimOr" -> \case [EBool x, EBool y] -> EBool (x || y); xs -> f xs
509 "PrimXor" -> \case [EBool x, EBool y] -> EBool (x /= y); xs -> f xs 519 "PrimXor" -> \case [EBool x, EBool y] -> EBool (x /= y); xs -> f xs
510 "PrimNot" -> \case [_, _, _, EBool x] -> EBool $ not x; xs -> f xs 520 "PrimNot" -> \case [TNat, _, _, EBool x] -> EBool $ not x; xs -> f xs
511 521
512 _ -> f 522 _ -> f
513 where 523 where
@@ -521,7 +531,7 @@ cstr = f []
521 f ns typ (FixLabel _ a) a' = f ns typ a a' 531 f ns typ (FixLabel _ a) a' = f ns typ a a'
522 f ns typ a (FixLabel _ a') = f ns typ a a' 532 f ns typ a (FixLabel _ a') = f ns typ a a'
523 f ns typ (Con a n xs) (Con a' n' xs') | a == a' && n == n' && length xs == length xs' = 533 f ns typ (Con a n xs) (Con a' n' xs') | a == a' && n == n' && length xs == length xs' =
524 if null xs then Unit else ff ns (foldl appTy (nType a) $ mkConPars n typ) $ zip xs xs' 534 if null xs then Unit else ff ns (foldl appTy (conType typ a) $ mkConPars n typ) $ zip xs xs'
525 f ns typ (TyCon a xs) (TyCon a' xs') | a == a' && length xs == length xs' = 535 f ns typ (TyCon a xs) (TyCon a' xs') | a == a' && length xs == length xs' =
526 ff ns (nType a) $ zip xs xs' 536 ff ns (nType a) $ zip xs xs'
527 f (_: ns) typ{-down?-} (down 0 -> Just a) (down 0 -> Just a') = f ns typ a a' 537 f (_: ns) typ{-down?-} (down 0 -> Just a) (down 0 -> Just a') = f ns typ a a'
@@ -537,9 +547,9 @@ cstr = f []
537 547
538 f ns@[] TType (TyConN "'Tuple2" [x, y]) (UFunN "'JoinTupleType" [x', y']) = t2 (f ns TType x x') (f ns TType y y') 548 f ns@[] TType (TyConN "'Tuple2" [x, y]) (UFunN "'JoinTupleType" [x', y']) = t2 (f ns TType x x') (f ns TType y y')
539 f ns@[] TType (UFunN "'JoinTupleType" [x', y']) (TyConN "'Tuple2" [x, y]) = t2 (f ns TType x' x) (f ns TType y' y) 549 f ns@[] TType (UFunN "'JoinTupleType" [x', y']) (TyConN "'Tuple2" [x, y]) = t2 (f ns TType x' x) (f ns TType y' y)
540 f ns@[] TType (UFunN "'JoinTupleType" [x', y']) x@NoTup = t2 (f ns TType x' x) (f ns TType y' $ TTyCon0 "'Tuple0") 550 f ns@[] TType (UFunN "'JoinTupleType" [x', y']) x@NoTup = t2 (f ns TType x' x) (f ns TType y' TTuple0)
541 551
542 f ns@[] TType (x@NoTup) (UFunN "'InterpolatedType" [x']) = f ns TType (TTyCon "'Interpolated" (TType :~> TType) [x]) x' 552 f ns@[] TType (x@NoTup) (UFunN "'InterpolatedType" [x']) = f ns TType (TInterpolated x) x'
543 553
544 f [] typ a@Neut{} a' = CstrT typ a a' 554 f [] typ a@Neut{} a' = CstrT typ a a'
545 f [] typ a a'@Neut{} = CstrT typ a a' 555 f [] typ a a'@Neut{} = CstrT typ a a'
@@ -593,13 +603,13 @@ twoOp_ _ _ _ _ = Nothing
593 603
594modF x y = x - fromIntegral (floor (x / y)) * y 604modF x y = x - fromIntegral (floor (x / y)) * y
595 605
596twoOpBool :: (forall a . Ord a => a -> a -> Bool) -> Exp -> Exp -> Maybe Exp 606twoOpBool :: (forall a . Ord a => a -> a -> Bool) -> Exp -> Exp -> Exp -> Maybe Exp
597twoOpBool f (EFloat x) (EFloat y) = Just $ EBool $ f x y 607twoOpBool f t (EFloat x) (EFloat y) = Just $ EBool $ f x y
598twoOpBool f (EInt x) (EInt y) = Just $ EBool $ f x y 608twoOpBool f t (EInt x) (EInt y) = Just $ EBool $ f x y
599twoOpBool f (EString x) (EString y) = Just $ EBool $ f x y 609twoOpBool f t (EString x) (EString y) = Just $ EBool $ f x y
600twoOpBool f (EChar x) (EChar y) = Just $ EBool $ f x y 610twoOpBool f t (EChar x) (EChar y) = Just $ EBool $ f x y
601twoOpBool f (ENat x) (ENat y) = Just $ EBool $ f x y 611twoOpBool f TNat (ENat x) (ENat y) = Just $ EBool $ f x y
602twoOpBool _ _ _ = Nothing 612twoOpBool _ _ _ _ = Nothing
603 613
604app_ :: Exp -> Exp -> Exp 614app_ :: Exp -> Exp -> Exp
605app_ (Lam x) a = subst 0 a x 615app_ (Lam x) a = subst 0 a x
@@ -705,11 +715,13 @@ litType = \case
705class NType a where nType :: a -> Type 715class NType a where nType :: a -> Type
706 716
707instance NType FunName where nType (FunName _ _ t) = t 717instance NType FunName where nType (FunName _ _ t) = t
708instance NType ConName where nType (ConName _ _ _ _ t) = t 718--instance NType ConName where nType (ConName _ _ _ t) = t
709instance NType TyConName where nType (TyConName _ _ _ t _ _) = t 719instance NType TyConName where nType (TyConName _ _ _ t _ _) = t
710instance NType CaseFunName where nType (CaseFunName _ t _) = t 720instance NType CaseFunName where nType (CaseFunName _ t _) = t
711instance NType TyCaseFunName where nType (TyCaseFunName _ t) = t 721instance NType TyCaseFunName where nType (TyCaseFunName _ t) = t
712 722
723conType (snd . getParams -> TyCon (TyConName _ _ _ _ cs _) _) (ConName _ _ n t) = t -- snd $ cs !! n
724
713neutType te = \case 725neutType te = \case
714 App_ f x -> appTy (neutType te f) x 726 App_ f x -> appTy (neutType te f) x
715 Var_ i -> snd $ varType "C" i te 727 Var_ i -> snd $ varType "C" i te
@@ -962,7 +974,7 @@ recheck' msg' e (x, xt) = (recheck_ "main" (checkEnv e) (x, xt), xt)
962 (Neut (App_ a b), zt) 974 (Neut (App_ a b), zt)
963 | (Neut a', at) <- recheck'' "app1" te (Neut a, neutType te a) 975 | (Neut a', at) <- recheck'' "app1" te (Neut a, neutType te a)
964 -> checkApps "a" [] zt (Neut . App_ a' . head) te at [b] 976 -> checkApps "a" [] zt (Neut . App_ a' . head) te at [b]
965 (Con s n as, zt) -> checkApps (show s) [] zt (Con s n . drop (conParams s)) te (nType s) $ mkConPars n zt ++ as 977 (Con s n as, zt) -> checkApps (show s) [] zt (Con s n . drop (conParams s)) te (conType zt s) $ mkConPars n zt ++ as
966 (TyCon s as, zt) -> checkApps (show s) [] zt (TyCon s) te (nType s) as 978 (TyCon s as, zt) -> checkApps (show s) [] zt (TyCon s) te (nType s) as
967 (Fun s as, zt) -> checkApps (show s ++ ppShow as ++ ppShow (nType s)) [] zt (Fun s) te (nType s) as 979 (Fun s as, zt) -> checkApps (show s ++ ppShow as ++ ppShow (nType s)) [] zt (Fun s) te (nType s) as
968 (CaseFun s@(CaseFunName _ t pars) as n, zt) -> checkApps (show s) [] zt (\xs -> evalCaseFun s (init $ drop pars xs) (last xs)) te (nType s) (makeCaseFunPars te n ++ as ++ [Neut n]) 980 (CaseFun s@(CaseFunName _ t pars) as n, zt) -> checkApps (show s) [] zt (\xs -> evalCaseFun s (init $ drop pars xs) (last xs)) te (nType s) (makeCaseFunPars te n ++ as ++ [Neut n])
@@ -1049,7 +1061,7 @@ extractDesugarInfo :: GlobalEnv -> DesugarInfo
1049extractDesugarInfo ge = 1061extractDesugarInfo ge =
1050 ( Map.fromList 1062 ( Map.fromList
1051 [ (n, f) | (n, (d, _, si)) <- Map.toList ge, f <- maybeToList $ case d of 1063 [ (n, f) | (n, (d, _, si)) <- Map.toList ge, f <- maybeToList $ case d of
1052 Con (ConName _ f _ _ _) 0 [] -> f 1064 Con (ConName _ f _ _) 0 [] -> f
1053 TyCon (TyConName _ f _ _ _ _) [] -> f 1065 TyCon (TyConName _ f _ _ _ _) [] -> f
1054 (getLams -> (Fun (FunName _ f _) [])) -> f 1066 (getLams -> (Fun (FunName _ f _) [])) -> f
1055 PMLabel (FunName _ f _) _ [] _ -> f 1067 PMLabel (FunName _ f _) _ [] _ -> f
@@ -1065,7 +1077,7 @@ extractDesugarInfo ge =
1065 ] 1077 ]
1066 ) 1078 )
1067 where 1079 where
1068 f (ConName n _ _ _ ct) = (n, pars ct) 1080 f (ConName n _ _ _, ct) = (n, pars ct)
1069 pars = length . filter ((==Visible) . fst) . fst . getParams 1081 pars = length . filter ((==Visible) . fst) . fst . getParams
1070 1082
1071-------------------------------------------------------------------------------- infos 1083-------------------------------------------------------------------------------- infos
@@ -1116,7 +1128,7 @@ handleStmt defs = \case
1116 acts = map fst . fst . getParams $ cty 1128 acts = map fst . fst . getParams $ cty
1117 conn = conName (snd cn) (listToMaybe [f | PrecDef n f <- defs, n == cn]) j cty 1129 conn = conName (snd cn) (listToMaybe [f | PrecDef n f <- defs, n == cn]) j cty
1118 addToEnv cn (Con conn 0 [], cty) 1130 addToEnv cn (Con conn 0 [], cty)
1119 return ( conn 1131 return ( (conn, cty)
1120 , addParamsS pars 1132 , addParamsS pars
1121 $ foldl SAppV (SVar (debugSI "22", ".cs") $ j + length pars) $ drop pnum' xs ++ [apps' (SGlobal cn) (zip acts $ downToS (j+1+length pars) (length ps) ++ downToS 0 (act- length ps))] 1133 $ foldl SAppV (SVar (debugSI "22", ".cs") $ j + length pars) $ drop pnum' xs ++ [apps' (SGlobal cn) (zip acts $ downToS (j+1+length pars) (length ps) ++ downToS 0 (act- length ps))]
1122 ) 1134 )
@@ -1330,7 +1342,7 @@ instance MkDoc Exp where
1330-- Lam h a b -> join $ shLam (used 0 b) (BLam h) <$> f a <*> pure (f b) 1342-- Lam h a b -> join $ shLam (used 0 b) (BLam h) <$> f a <*> pure (f b)
1331 Lam b -> join $ shLam True (BLam Visible) <$> f TType{-todo-} <*> pure (f b) 1343 Lam b -> join $ shLam True (BLam Visible) <$> f TType{-todo-} <*> pure (f b)
1332 Pi h a b -> join $ shLam (used 0 b) (BPi h) <$> f a <*> pure (f b) 1344 Pi h a b -> join $ shLam (used 0 b) (BPi h) <$> f a <*> pure (f b)
1333 ENat n -> pure $ shAtom $ show n 1345 ENat' n -> pure $ shAtom $ show n
1334 Con s _ xs -> foldl (shApp Visible) (shAtom_ $ show s) <$> mapM f xs 1346 Con s _ xs -> foldl (shApp Visible) (shAtom_ $ show s) <$> mapM f xs
1335 TyConN s xs -> foldl (shApp Visible) (shAtom_ s) <$> mapM f xs 1347 TyConN s xs -> foldl (shApp Visible) (shAtom_ s) <$> mapM f xs
1336 TType -> pure $ shAtom "Type" 1348 TType -> pure $ shAtom "Type"
diff --git a/testdata/Builtins.out b/testdata/Builtins.out
index a83047df..1735f193 100644
--- a/testdata/Builtins.out
+++ b/testdata/Builtins.out
@@ -1979,19 +1979,19 @@ testdata/Builtins.lc 464:42-464:46 Type
1979testdata/Builtins.lc 464:42-464:54 Type 1979testdata/Builtins.lc 464:42-464:54 Type
1980testdata/Builtins.lc 464:50-464:54 Type 1980testdata/Builtins.lc 464:50-464:54 Type
1981testdata/Builtins.lc 465:1-465:8 {a} -> {b:Nat} -> {c : a ~ VecScalar b Bool} -> a->a 1981testdata/Builtins.lc 465:1-465:8 {a} -> {b:Nat} -> {c : a ~ VecScalar b Bool} -> a->a
1982testdata/Builtins.lc 465:34-465:56 Type 1982testdata/Builtins.lc 465:47-465:69 Type
1983testdata/Builtins.lc 465:34-465:66 Type 1983testdata/Builtins.lc 465:47-465:79 Type
1984testdata/Builtins.lc 465:35-465:36 V3 1984testdata/Builtins.lc 465:48-465:49 V3
1985testdata/Builtins.lc 465:35-465:38 Type->Type 1985testdata/Builtins.lc 465:48-465:51 Type->Type
1986testdata/Builtins.lc 465:37-465:38 Type -> Type->Type 1986testdata/Builtins.lc 465:50-465:51 Type -> Type->Type
1987testdata/Builtins.lc 465:39-465:48 Nat -> Type->Type 1987testdata/Builtins.lc 465:52-465:61 Nat -> Type->Type
1988testdata/Builtins.lc 465:39-465:50 Type->Type 1988testdata/Builtins.lc 465:52-465:63 Type->Type
1989testdata/Builtins.lc 465:39-465:55 Type 1989testdata/Builtins.lc 465:52-465:68 Type
1990testdata/Builtins.lc 465:49-465:50 V1 1990testdata/Builtins.lc 465:62-465:63 V1
1991testdata/Builtins.lc 465:51-465:55 Type 1991testdata/Builtins.lc 465:64-465:68 Type
1992testdata/Builtins.lc 465:60-465:61 Type 1992testdata/Builtins.lc 465:73-465:74 Type
1993testdata/Builtins.lc 465:60-465:66 Type 1993testdata/Builtins.lc 465:73-465:79 Type
1994testdata/Builtins.lc 465:65-465:66 Type 1994testdata/Builtins.lc 465:78-465:79 Type
1995testdata/Builtins.lc 466:1-466:8 {a:Nat} -> VecScalar a Bool -> Bool 1995testdata/Builtins.lc 466:1-466:8 {a:Nat} -> VecScalar a Bool -> Bool
1996testdata/Builtins.lc 466:10-466:17 {a:Nat} -> VecScalar a Bool -> Bool 1996testdata/Builtins.lc 466:10-466:17 {a:Nat} -> VecScalar a Bool -> Bool
1997testdata/Builtins.lc 466:34-466:43 Nat -> Type->Type 1997testdata/Builtins.lc 466:34-466:43 Nat -> Type->Type
@@ -2618,56 +2618,56 @@ testdata/Builtins.lc 509:60-509:69 Type
2618testdata/Builtins.lc 509:64-509:65 Nat 2618testdata/Builtins.lc 509:64-509:65 Nat
2619testdata/Builtins.lc 509:66-509:67 Nat 2619testdata/Builtins.lc 509:66-509:67 Nat
2620testdata/Builtins.lc 509:68-509:69 Type 2620testdata/Builtins.lc 509:68-509:69 Type
2621testdata/Builtins.lc 511:1-511:13 {a} -> {b} -> {c:Nat} -> {d} -> {e : Num a} -> {f : b ~ VecScalar c a} -> {g : d ~ VecScalar c Bool} -> b -> b->d 2621testdata/Builtins.lc 511:1-511:13 {a} -> {b:Nat} -> {c} -> {d} -> {e : Num c} -> {f : a ~ VecScalar b c} -> {g : d ~ VecScalar b Bool} -> a -> a->d
2622testdata/Builtins.lc 511:15-511:32 {a} -> {b} -> {c:Nat} -> {d} -> {e : Num a} -> {f : b ~ VecScalar c a} -> {g : d ~ VecScalar c Bool} -> b -> b->d 2622testdata/Builtins.lc 511:15-511:32 {a} -> {b:Nat} -> {c} -> {d} -> {e : Num c} -> {f : a ~ VecScalar b c} -> {g : d ~ VecScalar b Bool} -> a -> a->d
2623testdata/Builtins.lc 511:34-511:49 {a} -> {b} -> {c:Nat} -> {d} -> {e : Num a} -> {f : b ~ VecScalar c a} -> {g : d ~ VecScalar c Bool} -> b -> b->d 2623testdata/Builtins.lc 511:34-511:49 {a} -> {b:Nat} -> {c} -> {d} -> {e : Num c} -> {f : a ~ VecScalar b c} -> {g : d ~ VecScalar b Bool} -> a -> a->d
2624testdata/Builtins.lc 511:51-511:71 {a} -> {b} -> {c:Nat} -> {d} -> {e : Num a} -> {f : b ~ VecScalar c a} -> {g : d ~ VecScalar c Bool} -> b -> b->d 2624testdata/Builtins.lc 511:51-511:71 {a} -> {b:Nat} -> {c} -> {d} -> {e : Num c} -> {f : a ~ VecScalar b c} -> {g : d ~ VecScalar b Bool} -> a -> a->d
2625testdata/Builtins.lc 511:73-511:83 {a} -> {b} -> {c:Nat} -> {d} -> {e : Num a} -> {f : b ~ VecScalar c a} -> {g : d ~ VecScalar c Bool} -> b -> b->d 2625testdata/Builtins.lc 511:73-511:83 {a} -> {b:Nat} -> {c} -> {d} -> {e : Num c} -> {f : a ~ VecScalar b c} -> {g : d ~ VecScalar b Bool} -> a -> a->d
2626testdata/Builtins.lc 511:85-511:98 {a} -> {b} -> {c:Nat} -> {d} -> {e : Num a} -> {f : b ~ VecScalar c a} -> {g : d ~ VecScalar c Bool} -> b -> b->d 2626testdata/Builtins.lc 511:85-511:98 {a} -> {b:Nat} -> {c} -> {d} -> {e : Num c} -> {f : a ~ VecScalar b c} -> {g : d ~ VecScalar b Bool} -> a -> a->d
2627testdata/Builtins.lc 512:34-512:97 Type 2627testdata/Builtins.lc 512:51-512:114 Type
2628testdata/Builtins.lc 512:35-512:38 Type->Type 2628testdata/Builtins.lc 512:52-512:55 Type->Type
2629testdata/Builtins.lc 512:35-512:40 Type 2629testdata/Builtins.lc 512:52-512:57 Type
2630testdata/Builtins.lc 512:39-512:40 V7 2630testdata/Builtins.lc 512:56-512:57 V3
2631testdata/Builtins.lc 512:42-512:43 V6 2631testdata/Builtins.lc 512:59-512:60 V7
2632testdata/Builtins.lc 512:42-512:45 Type->Type 2632testdata/Builtins.lc 512:59-512:62 Type->Type
2633testdata/Builtins.lc 512:42-512:59 Type 2633testdata/Builtins.lc 512:59-512:76 Type
2634testdata/Builtins.lc 512:42-512:97 Type 2634testdata/Builtins.lc 512:59-512:114 Type
2635testdata/Builtins.lc 512:44-512:45 Type -> Type->Type 2635testdata/Builtins.lc 512:61-512:62 Type -> Type->Type
2636testdata/Builtins.lc 512:46-512:55 Nat -> Type->Type 2636testdata/Builtins.lc 512:63-512:72 Nat -> Type->Type
2637testdata/Builtins.lc 512:46-512:57 Type->Type 2637testdata/Builtins.lc 512:63-512:74 Type->Type
2638testdata/Builtins.lc 512:46-512:59 Type 2638testdata/Builtins.lc 512:63-512:76 Type
2639testdata/Builtins.lc 512:56-512:57 V4 2639testdata/Builtins.lc 512:73-512:74 V5
2640testdata/Builtins.lc 512:58-512:59 Type 2640testdata/Builtins.lc 512:75-512:76 Type
2641testdata/Builtins.lc 512:61-512:62 V3 2641testdata/Builtins.lc 512:78-512:79 V3
2642testdata/Builtins.lc 512:61-512:64 Type->Type 2642testdata/Builtins.lc 512:78-512:81 Type->Type
2643testdata/Builtins.lc 512:61-512:81 Type 2643testdata/Builtins.lc 512:78-512:98 Type
2644testdata/Builtins.lc 512:61-512:97 Type 2644testdata/Builtins.lc 512:78-512:114 Type
2645testdata/Builtins.lc 512:63-512:64 Type -> Type->Type 2645testdata/Builtins.lc 512:80-512:81 Type -> Type->Type
2646testdata/Builtins.lc 512:65-512:74 Nat -> Type->Type 2646testdata/Builtins.lc 512:82-512:91 Nat -> Type->Type
2647testdata/Builtins.lc 512:65-512:76 Type->Type 2647testdata/Builtins.lc 512:82-512:93 Type->Type
2648testdata/Builtins.lc 512:65-512:81 Type 2648testdata/Builtins.lc 512:82-512:98 Type
2649testdata/Builtins.lc 512:75-512:76 Nat 2649testdata/Builtins.lc 512:92-512:93 Nat
2650testdata/Builtins.lc 512:77-512:81 Type 2650testdata/Builtins.lc 512:94-512:98 Type
2651testdata/Builtins.lc 512:86-512:87 Type 2651testdata/Builtins.lc 512:103-512:104 Type
2652testdata/Builtins.lc 512:86-512:97 Type 2652testdata/Builtins.lc 512:103-512:114 Type
2653testdata/Builtins.lc 512:91-512:92 Type 2653testdata/Builtins.lc 512:108-512:109 Type
2654testdata/Builtins.lc 512:91-512:97 Type 2654testdata/Builtins.lc 512:108-512:114 Type
2655testdata/Builtins.lc 512:96-512:97 Type 2655testdata/Builtins.lc 512:113-512:114 Type
2656testdata/Builtins.lc 513:1-513:10 {a} -> {b} -> {c : a ~ MatVecScalarElem b} -> b -> b->Bool 2656testdata/Builtins.lc 513:1-513:10 {a} -> {b} -> {c : b ~ MatVecScalarElem a} -> a -> a->Bool
2657testdata/Builtins.lc 513:12-513:24 {a} -> {b} -> {c : a ~ MatVecScalarElem b} -> b -> b->Bool 2657testdata/Builtins.lc 513:12-513:24 {a} -> {b} -> {c : b ~ MatVecScalarElem a} -> a -> a->Bool
2658testdata/Builtins.lc 513:34-513:58 Type 2658testdata/Builtins.lc 513:47-513:71 Type
2659testdata/Builtins.lc 513:34-513:76 Type 2659testdata/Builtins.lc 513:47-513:89 Type
2660testdata/Builtins.lc 513:35-513:36 V3 2660testdata/Builtins.lc 513:48-513:49 V1
2661testdata/Builtins.lc 513:35-513:38 Type->Type 2661testdata/Builtins.lc 513:48-513:51 Type->Type
2662testdata/Builtins.lc 513:37-513:38 Type -> Type->Type 2662testdata/Builtins.lc 513:50-513:51 Type -> Type->Type
2663testdata/Builtins.lc 513:39-513:55 Type->Type 2663testdata/Builtins.lc 513:52-513:68 Type->Type
2664testdata/Builtins.lc 513:39-513:57 Type 2664testdata/Builtins.lc 513:52-513:70 Type
2665testdata/Builtins.lc 513:56-513:57 V1 2665testdata/Builtins.lc 513:69-513:70 V2
2666testdata/Builtins.lc 513:62-513:63 Type 2666testdata/Builtins.lc 513:75-513:76 Type
2667testdata/Builtins.lc 513:62-513:76 Type 2667testdata/Builtins.lc 513:75-513:89 Type
2668testdata/Builtins.lc 513:67-513:68 Type 2668testdata/Builtins.lc 513:80-513:81 Type
2669testdata/Builtins.lc 513:67-513:76 Type 2669testdata/Builtins.lc 513:80-513:89 Type
2670testdata/Builtins.lc 513:72-513:76 Type 2670testdata/Builtins.lc 513:85-513:89 Type
2671testdata/Builtins.lc 515:1-515:9 {a} -> {b:Nat} -> {c : a ~ VecScalar b Float} -> a->a 2671testdata/Builtins.lc 515:1-515:9 {a} -> {b:Nat} -> {c : a ~ VecScalar b Float} -> a->a
2672testdata/Builtins.lc 515:11-515:19 {a} -> {b:Nat} -> {c : a ~ VecScalar b Float} -> a->a 2672testdata/Builtins.lc 515:11-515:19 {a} -> {b:Nat} -> {c : a ~ VecScalar b Float} -> a->a
2673testdata/Builtins.lc 515:21-515:31 {a} -> {b:Nat} -> {c : a ~ VecScalar b Float} -> a->a 2673testdata/Builtins.lc 515:21-515:31 {a} -> {b:Nat} -> {c : a ~ VecScalar b Float} -> a->a
diff --git a/testdata/Prelude.out b/testdata/Prelude.out
index 7dc75db8..b741d271 100644
--- a/testdata/Prelude.out
+++ b/testdata/Prelude.out
@@ -753,33 +753,33 @@ testdata/Prelude.lc 269:9-269:16 {a} -> {b : Signed (MatVecScalarElem a)} -> a-
753testdata/Prelude.lc 269:9-269:18 V2 753testdata/Prelude.lc 269:9-269:18 V2
754testdata/Prelude.lc 269:17-269:18 V3 754testdata/Prelude.lc 269:17-269:18 V3
755testdata/Prelude.lc 273:3-273:5 {a} -> a -> a->Bool 755testdata/Prelude.lc 273:3-273:5 {a} -> a -> a->Bool
756testdata/Prelude.lc 273:10-273:22 {a} -> {b} -> {c : a ~ MatVecScalarElem b} -> b -> b->Bool 756testdata/Prelude.lc 273:10-273:22 {a} -> {b} -> {c : b ~ MatVecScalarElem a} -> a -> a->Bool
757testdata/Prelude.lc 273:10-273:24 V3->Bool 757testdata/Prelude.lc 273:10-273:24 V3->Bool
758testdata/Prelude.lc 273:10-273:26 Bool 758testdata/Prelude.lc 273:10-273:26 Bool
759testdata/Prelude.lc 273:23-273:24 V4 759testdata/Prelude.lc 273:23-273:24 V4
760testdata/Prelude.lc 273:25-273:26 V1 760testdata/Prelude.lc 273:25-273:26 V1
761testdata/Prelude.lc 274:3-274:4 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 761testdata/Prelude.lc 274:3-274:4 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
762testdata/Prelude.lc 274:9-274:21 {a} -> {b} -> {c:Nat} -> {d} -> {e : Num a} -> {f : b ~ VecScalar c a} -> {g : d ~ VecScalar c Bool} -> b -> b->d 762testdata/Prelude.lc 274:9-274:21 {a} -> {b:Nat} -> {c} -> {d} -> {e : Num c} -> {f : a ~ VecScalar b c} -> {g : d ~ VecScalar b Bool} -> a -> a->d
763testdata/Prelude.lc 274:9-274:23 VecScalar V1 V2 -> VecScalar V2 Bool 763testdata/Prelude.lc 274:9-274:23 VecScalar V2 V1 -> VecScalar V3 Bool
764testdata/Prelude.lc 274:9-274:25 VecScalar V1 Bool 764testdata/Prelude.lc 274:9-274:25 VecScalar V2 Bool
765testdata/Prelude.lc 274:22-274:23 V6 765testdata/Prelude.lc 274:22-274:23 V6
766testdata/Prelude.lc 274:24-274:25 V4 766testdata/Prelude.lc 274:24-274:25 V4
767testdata/Prelude.lc 275:3-275:5 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 767testdata/Prelude.lc 275:3-275:5 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
768testdata/Prelude.lc 275:10-275:27 {a} -> {b} -> {c:Nat} -> {d} -> {e : Num a} -> {f : b ~ VecScalar c a} -> {g : d ~ VecScalar c Bool} -> b -> b->d 768testdata/Prelude.lc 275:10-275:27 {a} -> {b:Nat} -> {c} -> {d} -> {e : Num c} -> {f : a ~ VecScalar b c} -> {g : d ~ VecScalar b Bool} -> a -> a->d
769testdata/Prelude.lc 275:10-275:29 VecScalar V1 V2 -> VecScalar V2 Bool 769testdata/Prelude.lc 275:10-275:29 VecScalar V2 V1 -> VecScalar V3 Bool
770testdata/Prelude.lc 275:10-275:31 VecScalar V1 Bool 770testdata/Prelude.lc 275:10-275:31 VecScalar V2 Bool
771testdata/Prelude.lc 275:28-275:29 V6 771testdata/Prelude.lc 275:28-275:29 V6
772testdata/Prelude.lc 275:30-275:31 V4 772testdata/Prelude.lc 275:30-275:31 V4
773testdata/Prelude.lc 276:3-276:5 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 773testdata/Prelude.lc 276:3-276:5 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
774testdata/Prelude.lc 276:10-276:30 {a} -> {b} -> {c:Nat} -> {d} -> {e : Num a} -> {f : b ~ VecScalar c a} -> {g : d ~ VecScalar c Bool} -> b -> b->d 774testdata/Prelude.lc 276:10-276:30 {a} -> {b:Nat} -> {c} -> {d} -> {e : Num c} -> {f : a ~ VecScalar b c} -> {g : d ~ VecScalar b Bool} -> a -> a->d
775testdata/Prelude.lc 276:10-276:32 VecScalar V1 V2 -> VecScalar V2 Bool 775testdata/Prelude.lc 276:10-276:32 VecScalar V2 V1 -> VecScalar V3 Bool
776testdata/Prelude.lc 276:10-276:34 VecScalar V1 Bool 776testdata/Prelude.lc 276:10-276:34 VecScalar V2 Bool
777testdata/Prelude.lc 276:31-276:32 V6 777testdata/Prelude.lc 276:31-276:32 V6
778testdata/Prelude.lc 276:33-276:34 V4 778testdata/Prelude.lc 276:33-276:34 V4
779testdata/Prelude.lc 277:3-277:4 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 779testdata/Prelude.lc 277:3-277:4 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
780testdata/Prelude.lc 277:9-277:24 {a} -> {b} -> {c:Nat} -> {d} -> {e : Num a} -> {f : b ~ VecScalar c a} -> {g : d ~ VecScalar c Bool} -> b -> b->d 780testdata/Prelude.lc 277:9-277:24 {a} -> {b:Nat} -> {c} -> {d} -> {e : Num c} -> {f : a ~ VecScalar b c} -> {g : d ~ VecScalar b Bool} -> a -> a->d
781testdata/Prelude.lc 277:9-277:26 VecScalar V1 V2 -> VecScalar V2 Bool 781testdata/Prelude.lc 277:9-277:26 VecScalar V2 V1 -> VecScalar V3 Bool
782testdata/Prelude.lc 277:9-277:28 VecScalar V1 Bool 782testdata/Prelude.lc 277:9-277:28 VecScalar V2 Bool
783testdata/Prelude.lc 277:25-277:26 V6 783testdata/Prelude.lc 277:25-277:26 V6
784testdata/Prelude.lc 277:27-277:28 V4 784testdata/Prelude.lc 277:27-277:28 V4
785testdata/Prelude.lc 280:3-280:5 Bool -> Bool->Bool 785testdata/Prelude.lc 280:3-280:5 Bool -> Bool->Bool
@@ -1048,7 +1048,7 @@ testdata/Prelude.lc 358:17-358:18 Float
1048testdata/Prelude.lc 358:17-358:20 Float->Bool 1048testdata/Prelude.lc 358:17-358:20 Float->Bool
1049testdata/Prelude.lc 358:17-358:22 Bool 1049testdata/Prelude.lc 358:17-358:22 Bool
1050testdata/Prelude.lc 358:17-358:30 List V0 -> List V1 1050testdata/Prelude.lc 358:17-358:30 List V0 -> List V1
1051testdata/Prelude.lc 358:19-358:20 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 1051testdata/Prelude.lc 358:19-358:20 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
1052testdata/Prelude.lc 358:21-358:22 Float 1052testdata/Prelude.lc 358:21-358:22 Float
1053testdata/Prelude.lc 358:28-358:30 {a} -> List a 1053testdata/Prelude.lc 358:28-358:30 {a} -> List a
1054testdata/Prelude.lc 358:36-358:37 Float 1054testdata/Prelude.lc 358:36-358:37 Float
diff --git a/testdata/complex.out b/testdata/complex.out
index 608be18c..444cab15 100644
--- a/testdata/complex.out
+++ b/testdata/complex.out
@@ -92,7 +92,7 @@ testdata/complex.lc 24:11-24:12 Float
92testdata/complex.lc 24:11-24:14 Float->Bool 92testdata/complex.lc 24:11-24:14 Float->Bool
93testdata/complex.lc 24:11-24:19 Bool 93testdata/complex.lc 24:11-24:19 Bool
94testdata/complex.lc 24:11-24:59 Complex 'Polar -> Complex 'Polar 94testdata/complex.lc 24:11-24:59 Complex 'Polar -> Complex 'Polar
95testdata/complex.lc 24:13-24:14 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 95testdata/complex.lc 24:13-24:14 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
96testdata/complex.lc 24:16-24:19 Float 96testdata/complex.lc 24:16-24:19 Float
97testdata/complex.lc 24:37-24:42 Float -> Float -> Complex 'Polar 97testdata/complex.lc 24:37-24:42 Float -> Float -> Complex 'Polar
98testdata/complex.lc 24:37-24:44 Float -> Complex 'Polar 98testdata/complex.lc 24:37-24:44 Float -> Complex 'Polar
@@ -112,13 +112,13 @@ testdata/complex.lc 25:11-25:19 Bool
112testdata/complex.lc 25:11-25:22 Bool->Bool 112testdata/complex.lc 25:11-25:22 Bool->Bool
113testdata/complex.lc 25:11-25:31 Bool 113testdata/complex.lc 25:11-25:31 Bool
114testdata/complex.lc 25:11-25:64 Complex 'Polar -> Complex 'Polar 114testdata/complex.lc 25:11-25:64 Complex 'Polar -> Complex 'Polar
115testdata/complex.lc 25:13-25:14 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 115testdata/complex.lc 25:13-25:14 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
116testdata/complex.lc 25:16-25:19 Float 116testdata/complex.lc 25:16-25:19 Float
117testdata/complex.lc 25:20-25:22 Bool -> Bool->Bool 117testdata/complex.lc 25:20-25:22 Bool -> Bool->Bool
118testdata/complex.lc 25:23-25:24 Float 118testdata/complex.lc 25:23-25:24 Float
119testdata/complex.lc 25:23-25:27 Float->Bool 119testdata/complex.lc 25:23-25:27 Float->Bool
120testdata/complex.lc 25:23-25:31 Bool 120testdata/complex.lc 25:23-25:31 Bool
121testdata/complex.lc 25:25-25:27 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 121testdata/complex.lc 25:25-25:27 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
122testdata/complex.lc 25:28-25:31 Float 122testdata/complex.lc 25:28-25:31 Float
123testdata/complex.lc 25:37-25:42 Float -> Float -> Complex 'Polar 123testdata/complex.lc 25:37-25:42 Float -> Float -> Complex 'Polar
124testdata/complex.lc 25:37-25:44 Float -> Complex 'Polar 124testdata/complex.lc 25:37-25:44 Float -> Complex 'Polar
@@ -142,13 +142,13 @@ testdata/complex.lc 26:11-26:19 Bool
142testdata/complex.lc 26:11-26:22 Bool->Bool 142testdata/complex.lc 26:11-26:22 Bool->Bool
143testdata/complex.lc 26:11-26:31 Bool 143testdata/complex.lc 26:11-26:31 Bool
144testdata/complex.lc 26:11-26:64 Complex 'Polar -> Complex 'Polar 144testdata/complex.lc 26:11-26:64 Complex 'Polar -> Complex 'Polar
145testdata/complex.lc 26:13-26:14 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 145testdata/complex.lc 26:13-26:14 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
146testdata/complex.lc 26:16-26:19 Float 146testdata/complex.lc 26:16-26:19 Float
147testdata/complex.lc 26:20-26:22 Bool -> Bool->Bool 147testdata/complex.lc 26:20-26:22 Bool -> Bool->Bool
148testdata/complex.lc 26:23-26:24 Float 148testdata/complex.lc 26:23-26:24 Float
149testdata/complex.lc 26:23-26:26 Float->Bool 149testdata/complex.lc 26:23-26:26 Float->Bool
150testdata/complex.lc 26:23-26:31 Bool 150testdata/complex.lc 26:23-26:31 Bool
151testdata/complex.lc 26:25-26:26 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 151testdata/complex.lc 26:25-26:26 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
152testdata/complex.lc 26:28-26:31 Float 152testdata/complex.lc 26:28-26:31 Float
153testdata/complex.lc 26:37-26:42 Float -> Float -> Complex 'Polar 153testdata/complex.lc 26:37-26:42 Float -> Float -> Complex 'Polar
154testdata/complex.lc 26:37-26:44 Float -> Complex 'Polar 154testdata/complex.lc 26:37-26:44 Float -> Complex 'Polar
@@ -178,7 +178,7 @@ testdata/complex.lc 27:20-27:22 Bool -> Bool->Bool
178testdata/complex.lc 27:23-27:24 Float 178testdata/complex.lc 27:23-27:24 Float
179testdata/complex.lc 27:23-27:27 Float->Bool 179testdata/complex.lc 27:23-27:27 Float->Bool
180testdata/complex.lc 27:23-27:31 Bool 180testdata/complex.lc 27:23-27:31 Bool
181testdata/complex.lc 27:25-27:27 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 181testdata/complex.lc 27:25-27:27 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
182testdata/complex.lc 27:28-27:31 Float 182testdata/complex.lc 27:28-27:31 Float
183testdata/complex.lc 27:37-27:42 Float -> Float -> Complex 'Polar 183testdata/complex.lc 27:37-27:42 Float -> Float -> Complex 'Polar
184testdata/complex.lc 27:37-27:44 Float -> Complex 'Polar 184testdata/complex.lc 27:37-27:44 Float -> Complex 'Polar
@@ -202,7 +202,7 @@ testdata/complex.lc 28:20-28:22 Bool -> Bool->Bool
202testdata/complex.lc 28:23-28:24 Float 202testdata/complex.lc 28:23-28:24 Float
203testdata/complex.lc 28:23-28:26 Float->Bool 203testdata/complex.lc 28:23-28:26 Float->Bool
204testdata/complex.lc 28:23-28:31 Bool 204testdata/complex.lc 28:23-28:31 Bool
205testdata/complex.lc 28:25-28:26 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 205testdata/complex.lc 28:25-28:26 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
206testdata/complex.lc 28:28-28:31 Float 206testdata/complex.lc 28:28-28:31 Float
207testdata/complex.lc 28:37-28:42 Float -> Float -> Complex 'Polar 207testdata/complex.lc 28:37-28:42 Float -> Float -> Complex 'Polar
208testdata/complex.lc 28:37-28:44 Float -> Complex 'Polar 208testdata/complex.lc 28:37-28:44 Float -> Complex 'Polar
@@ -381,5 +381,5 @@ testdata/complex.lc 145:12-145:31 Bool
381testdata/complex.lc 145:17-145:25 Complex V0 381testdata/complex.lc 145:17-145:25 Complex V0
382testdata/complex.lc 145:18-145:22 {a:Repr} -> Complex a -> Complex a 382testdata/complex.lc 145:18-145:22 {a:Repr} -> Complex a -> Complex a
383testdata/complex.lc 145:23-145:24 V6 383testdata/complex.lc 145:23-145:24 V6
384testdata/complex.lc 145:26-145:27 {a} -> {b:Nat} -> {c : Num a} -> VecScalar b a -> VecScalar b a -> VecScalar b Bool 384testdata/complex.lc 145:26-145:27 {a:Nat} -> {b} -> {c : Num b} -> VecScalar a b -> VecScalar a b -> VecScalar a Bool
385testdata/complex.lc 145:28-145:31 Float 385testdata/complex.lc 145:28-145:31 Float