summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-02-19 12:39:50 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-02-19 12:40:05 +0100
commita4b6b7bae563d8d2cfdbb5afc3bde594dad7f77b (patch)
tree23a08e7b5ccb392b0deeb20a6849c7f0eb3b36ed
parent49b1a36e8bf97a4edd56d7890273566eaa895075 (diff)
speedup: tweak max de bruijn handling
-rw-r--r--lc/Builtins.lc26
-rw-r--r--lc/Internals.lc27
-rw-r--r--src/LambdaCube/Compiler/Infer.hs39
-rw-r--r--src/LambdaCube/Compiler/Lexer.hs6
-rw-r--r--src/LambdaCube/Compiler/Parser.hs30
-rw-r--r--test/UnitTests.hs8
-rw-r--r--testdata/language-features/recursion/mutualConst.lc9
7 files changed, 79 insertions, 66 deletions
diff --git a/lc/Builtins.lc b/lc/Builtins.lc
index a0b9e5e0..41cbbeb0 100644
--- a/lc/Builtins.lc
+++ b/lc/Builtins.lc
@@ -48,13 +48,29 @@ type family MatVecScalarElem a where
48 48
49--------------------------------------- swizzling 49--------------------------------------- swizzling
50 50
51data Swizz = Sx | Sy | Sz | Sw
52
53mapVec :: (a -> b) -> VecS a n -> VecS b n 51mapVec :: (a -> b) -> VecS a n -> VecS b n
54mapVec f (V2 x y) = V2 (f x) (f y) 52mapVec f (V2 x y) = V2 (f x) (f y)
55mapVec f (V3 x y z) = V3 (f x) (f y) (f z) 53mapVec f (V3 x y z) = V3 (f x) (f y) (f z)
56mapVec f (V4 x y z w) = V4 (f x) (f y) (f z) (f w) 54mapVec f (V4 x y z w) = V4 (f x) (f y) (f z) (f w)
57 55
56data Swizz = Sx | Sy | Sz | Sw
57
58data Swizz' :: Nat -> Type where
59 Sx' :: forall n . Swizz' (Succ n)
60 Sy' :: forall n . Swizz' (Succ (Succ n))
61 Sz' :: forall n . Swizz' (Succ (Succ (Succ n)))
62 Sw' :: forall n . Swizz' (Succ (Succ (Succ (Succ n))))
63
64swizzscalar' :: forall n -> Vec n a -> Swizz' n -> a
65{-
66swizzscalar' 2 = \x -> case x of
67 V2 x y -> \s -> case s of
68 Sx' -> x
69 Sy' -> y
70swizzscalar' 3 = \x -> case x of
71 V3 x y z -> \s -> case s of
72 Sx' -> x
73-}
58-- todo: make it more type safe 74-- todo: make it more type safe
59swizzscalar :: forall n . Vec n a -> Swizz -> a 75swizzscalar :: forall n . Vec n a -> Swizz -> a
60swizzscalar (V2 x y) Sx = x 76swizzscalar (V2 x y) Sx = x
@@ -392,13 +408,11 @@ remSemantics' :: [ImageSemantics] -> [Type]
392remSemantics' (Depth _: x) = map remSemantics x 408remSemantics' (Depth _: x) = map remSemantics x
393remSemantics' x = map remSemantics x 409remSemantics' x = map remSemantics x
394 410
395type family FragmentOperationSem a :: ImageSemantics 411type family FragmentOperationSem a :: ImageSemantics where FragmentOperationSem (FragmentOperation x) = x
396type instance FragmentOperationSem (FragmentOperation x) = x
397 412
398Accumulate :: forall (n :: Nat) (c :: [Type]) . (b ~ map FragmentOperationSem c) => HList c -> FragmentStream n (HList (remSemantics' b)) -> FrameBuffer n b -> FrameBuffer n b 413Accumulate :: forall (n :: Nat) (c :: [Type]) . (b ~ map FragmentOperationSem c) => HList c -> FragmentStream n (HList (remSemantics' b)) -> FrameBuffer n b -> FrameBuffer n b
399 414
400type family ImageSem a :: ImageSemantics 415type family ImageSem a :: ImageSemantics where ImageSem (Image n t) = t
401type instance ImageSem (Image n t) = t
402 416
403tfFrameBuffer t = map 'ImageSem t 417tfFrameBuffer t = map 'ImageSem t
404 418
diff --git a/lc/Internals.lc b/lc/Internals.lc
index 9005cb0f..6e61b4eb 100644
--- a/lc/Internals.lc
+++ b/lc/Internals.lc
@@ -127,36 +127,27 @@ data HList :: [Type] -> Type where
127 HNil :: HList '[] 127 HNil :: HList '[]
128 HCons :: x -> HList xs -> HList '(x: xs) 128 HCons :: x -> HList xs -> HList '(x: xs)
129 129
130hlistNilCase :: forall c -> c -> HList Nil -> c
130hlistConsCase 131hlistConsCase
131 :: forall (e :: Type) (f :: List Type) 132 :: forall (e :: Type) (f :: List Type)
132 . forall (c :: Unit -> Type) 133 . forall c
133 -> (e -> HList f -> c 'TT) 134 -> (e -> HList f -> c)
134 -> HList (Cons e f) 135 -> HList (Cons e f)
135 -> c 'TT 136 -> c
137
136{- 138{-
137-- TODO: unsafeCoerce is not really needed here 139-- TODO: unsafeCoerce is not really needed here
138hlistConsCase @e @f c fv x = 'HListCase 140hlistConsCase @e @f c fv x = 'HListCase
139 (\_ _ -> c TT) 141 (\_ _ -> c)
140 undefined 142 undefined
141 (\ @t @lt y ys -> fv (unsafeCoerce @t @e y) (unsafeCoerce @(HList lt) @(HList f) ys)) 143 (\ @t @lt y ys -> fv (unsafeCoerce @t @e y) (unsafeCoerce @(HList lt) @(HList f) ys))
142 x 144 x
143-} 145
144hlistNilCase :: forall (c :: Unit -> Type) -> c 'TT -> HList Nil -> c 'TT
145{-
146hlistNilCase c x v = 'HListCase 146hlistNilCase c x v = 'HListCase
147 (\_ _ -> c TT) 147 (\_ _ -> c)
148 x 148 x
149 (\_ _ -> undefined :: c TT) 149 (\_ _ -> undefined :: c)
150 v 150 v
151-} 151-}
152 152
153--testmt :: forall (t :: Type) -> t -> t
154--testmt 'Type = \'Tuple0 -> 'Tuple0
155--testmt t x = (match'Type (\q -> (q -> q)) (\x -> match'Tuple0 (\q -> & 'Type) 'Tuple0 x undefined) t undefined) x
156--testmt t x = (match'Type (\q -> (q -> q)) (\x -> match'Tuple0 (\q -> 'Type) 'Tuple0 x undefined) t undefined) x
157
158--type instance EqCT Type = \'Type 'Type -> 'Unit
159--type instance EqCT Type = \'(a, b) '(JoinTupleType a' b') -> '(T2 (EqCT Type a a') (EqCT Type b b'))
160
161joinTupleType = HCons
162 153
diff --git a/src/LambdaCube/Compiler/Infer.hs b/src/LambdaCube/Compiler/Infer.hs
index 9afa8a36..13e18411 100644
--- a/src/LambdaCube/Compiler/Infer.hs
+++ b/src/LambdaCube/Compiler/Infer.hs
@@ -107,7 +107,12 @@ pattern NoLE <- (isNoLabelEnd -> True)
107isNoLabelEnd (LabelEnd_ _) = False 107isNoLabelEnd (LabelEnd_ _) = False
108isNoLabelEnd _ = True 108isNoLabelEnd _ = True
109 109
110pattern Fun' f vs i xs n <- Fun_ _ f vs i xs n where Fun' f vs i xs n = Fun_ (foldMap maxDB_ vs <> foldMap maxDB_ xs {- <> iterateN i lowerDB (maxDB_ n)-}) f vs i xs n 110mconcat1 [] = mempty
111mconcat1 [x] = x
112mconcat1 xs = notClosed --foldl1 (<>) xs
113mconcat1' = mconcat
114
115pattern Fun' f vs i xs n <- Fun_ _ f vs i xs n where Fun' f vs i xs n = Fun_ (mconcat1 $ map maxDB_ vs ++ map maxDB_ xs {- <> iterateN i lowerDB (maxDB_ n)-}) f vs i xs n
111pattern Fun f i xs n = Fun' f [] i xs n 116pattern Fun f i xs n = Fun' f [] i xs n
112pattern UTFun a t b <- (unfixlabel -> Neut (Fun (FunName a _ t) _ (reverse -> b) NoLE)) 117pattern UTFun a t b <- (unfixlabel -> Neut (Fun (FunName a _ t) _ (reverse -> b) NoLE))
113pattern UFunN a b <- UTFun a _ b 118pattern UFunN a b <- UTFun a _ b
@@ -117,7 +122,7 @@ pattern DFun_ fn xs <- Fun fn 0 (reverse -> xs) (Delta _) where
117pattern TFun' a t b = DFun_ (FunName a Nothing t) b 122pattern TFun' a t b = DFun_ (FunName a Nothing t) b
118pattern TFun a t b = Neut (TFun' a t b) 123pattern TFun a t b = Neut (TFun' a t b)
119 124
120pattern CaseFun_ a b c <- CaseFun__ _ a b c where CaseFun_ a b c = CaseFun__ (foldMap maxDB_ b <> maxDB_ c) a b c 125pattern CaseFun_ a b c <- CaseFun__ _ a b c where CaseFun_ a b c = CaseFun__ (maxDB_ c <> foldMap maxDB_ b) a b c
121pattern TyCaseFun_ a b c <- TyCaseFun__ _ a b c where TyCaseFun_ a b c = TyCaseFun__ (foldMap maxDB_ b <> maxDB_ c) a b c 126pattern TyCaseFun_ a b c <- TyCaseFun__ _ a b c where TyCaseFun_ a b c = TyCaseFun__ (foldMap maxDB_ b <> maxDB_ c) a b c
122pattern App_ a b <- App__ _ a b where App_ a b = App__ (maxDB_ a <> maxDB_ b) a b 127pattern App_ a b <- App__ _ a b where App_ a b = App__ (maxDB_ a <> maxDB_ b) a b
123pattern CaseFun a b c = Neut (CaseFun_ a b c) 128pattern CaseFun a b c = Neut (CaseFun_ a b c)
@@ -141,7 +146,7 @@ makeCaseFunPars' te n = case neutType' te n of
141pattern Closed :: () => Up a => a -> a 146pattern Closed :: () => Up a => a -> a
142pattern Closed a <- a where Closed a = closedExp a 147pattern Closed a <- a where Closed a = closedExp a
143 148
144pattern Con x n y <- Con_ _ x n y where Con x n y = Con_ (foldMap maxDB_ y) x n y 149pattern Con x n y <- Con_ _ x n y where Con x n y = Con_ (mconcat1 $ map maxDB_ y) x n y
145pattern ConN s a <- Con (ConName s _ _) _ a 150pattern ConN s a <- Con (ConName s _ _) _ a
146pattern ConN' s a <- Con (ConName _ s _) _ a 151pattern ConN' s a <- Con (ConName _ s _) _ a
147tCon s i t a = Con (ConName s i t) 0 a 152tCon s i t a = Con (ConName s i t) 0 a
@@ -371,7 +376,7 @@ instance Up Neutral where
371 CaseFun__ md s as ne -> CaseFun__ (upDB n md) s (up_ n i <$> as) (up_ n i ne) 376 CaseFun__ md s as ne -> CaseFun__ (upDB n md) s (up_ n i <$> as) (up_ n i ne)
372 TyCaseFun__ md s as ne -> TyCaseFun__ (upDB n md) s (up_ n i <$> as) (up_ n i ne) 377 TyCaseFun__ md s as ne -> TyCaseFun__ (upDB n md) s (up_ n i <$> as) (up_ n i ne)
373 App__ md a b -> App__ (upDB n md) (up_ n i a) (up_ n i b) 378 App__ md a b -> App__ (upDB n md) (up_ n i a) (up_ n i b)
374 Fun' fn vs c x y -> Fun' fn (up_ n i <$> vs) c (up_ n i <$> x) $ up_ n (i + c) y 379 Fun_ md fn vs c x y -> Fun_ (upDB n md) fn (up_ n i <$> vs) c (up_ n i <$> x) $ up_ n (i + c) y
375 LabelEnd_ x -> LabelEnd_ $ up_ n i x 380 LabelEnd_ x -> LabelEnd_ $ up_ n i x
376 d@Delta{} -> d 381 d@Delta{} -> d
377 382
@@ -755,6 +760,8 @@ inferN e s = do
755 f ITrace{} = False 760 f ITrace{} = False
756 f _ = True 761 f _ = True
757 762
763substTo i x = subst i x . up1_ (i+1)
764
758inferN_ :: forall m . Monad m => (forall a . String -> String -> IM m a -> IM m a) -> Env -> SExp2 -> IM m ExpType' 765inferN_ :: forall m . Monad m => (forall a . String -> String -> IM m a -> IM m a) -> Env -> SExp2 -> IM m ExpType'
759inferN_ tellTrace = infer where 766inferN_ tellTrace = infer where
760 767
@@ -779,12 +786,12 @@ inferN_ tellTrace = infer where
779 | x@(SGlobal (si, MatchName n)) `SAppV` SLamV (Wildcard _) `SAppV` a `SAppV` SVar siv v `SAppV` b <- e 786 | x@(SGlobal (si, MatchName n)) `SAppV` SLamV (Wildcard _) `SAppV` a `SAppV` SVar siv v `SAppV` b <- e
780 = infer te $ x `SAppV` SLam Visible SType (STyped mempty (subst (v+1) (Var 0) $ up 1 t, TType)) `SAppV` a `SAppV` SVar siv v `SAppV` b 787 = infer te $ x `SAppV` SLam Visible SType (STyped mempty (subst (v+1) (Var 0) $ up 1 t, TType)) `SAppV` a `SAppV` SVar siv v `SAppV` b
781 -- temporal hack 788 -- temporal hack
782 | x@(SGlobal (si, "'NatCase")) `SAppV` SLamV (Wildcard _) `SAppV` a `SAppV` b `SAppV` SVar siv v <- e 789 | x@(SGlobal (si, CaseName "'Nat")) `SAppV` SLamV (Wildcard _) `SAppV` a `SAppV` b `SAppV` SVar siv v <- e
783 = infer te $ x `SAppV` SLamV (STyped mempty (subst (v+1) (Var 0) $ up1_ (v+2) $ up 1 t, TType)) `SAppV` a `SAppV` b `SAppV` SVar siv v 790 = infer te $ x `SAppV` SLamV (STyped mempty (substTo (v+1) (Var 0) $ up 1 t, TType)) `SAppV` a `SAppV` b `SAppV` SVar siv v
784 -- temporal hack 791 -- temporal hack
785 | x@(SGlobal (si, "'VecSCase")) `SAppV` SLamV (SLamV (Wildcard _)) `SAppV` a `SAppV` b `SAppV` c `SAppV` SVar siv v <- e 792 | x@(SGlobal (si, CaseName "'VecS")) `SAppV` SLamV (SLamV (Wildcard _)) `SAppV` a `SAppV` b `SAppV` c `SAppV` SVar siv v <- e
786 , TVec (Var n') _ <- snd $ varType "xx" v te 793 , TyConN "'VecS" [_, Var n'] <- snd $ varType "xx" v te
787 = infer te $ x `SAppV` SLamV (SLamV (STyped mempty (subst (n'+2) (Var 1) $ up1_ (n'+3) $ up 2 t, TType))) `SAppV` a `SAppV` b `SAppV` c `SAppV` SVar siv v 794 = infer te $ x `SAppV` SLamV (SLamV (STyped mempty (substTo (n'+2) (Var 1) $ up 2 t, TType))) `SAppV` a `SAppV` b `SAppV` c `SAppV` SVar siv v
788 795
789{- 796{-
790 -- temporal hack 797 -- temporal hack
@@ -986,18 +993,18 @@ recheck' msg' e (x, xt) = (recheck_ "main" (checkEnv e) (x, xt), xt)
986 993
987 recheck_ msg te = \case 994 recheck_ msg te = \case
988 (Var k, zt) -> Var k -- todo: check var type 995 (Var k, zt) -> Var k -- todo: check var type
989 (Lam b, Pi h a bt) -> Lam $ recheck_ "9" (EBind2 (BLam h) a te) (b, bt) 996 (Lam_ md b, Pi h a bt) -> Lam_ md $ recheck_ "9" (EBind2 (BLam h) a te) (b, bt)
990 (Pi h a b, TType) -> Pi h (checkType te a) $ checkType (EBind2 (BPi h) a te) b 997 (Pi_ md h a b, TType) -> Pi_ md h (checkType te a) $ checkType (EBind2 (BPi h) a te) b
991 (ELit l, zt) -> ELit l -- todo: check literal type 998 (ELit l, zt) -> ELit l -- todo: check literal type
992 (TType, TType) -> TType 999 (TType, TType) -> TType
993 (Neut (App_ a b), zt) 1000 (Neut (App__ md a b), zt)
994 | (Neut a', at) <- recheck'' "app1" te (Neut a, neutType te a) 1001 | (Neut a', at) <- recheck'' "app1" te (Neut a, neutType te a)
995 -> checkApps "a" [] zt (Neut . App_ a' . head) te at [b] 1002 -> checkApps "a" [] zt (Neut . App__ md a' . head) te at [b]
996 (Con s n as, zt) -> checkApps (show s) [] zt (Con s n . drop (conParams s)) te (conType zt s) $ mkConPars n zt ++ as 1003 (Con_ md s n as, zt) -> checkApps (show s) [] zt (Con_ md s n . drop (conParams s)) te (conType zt s) $ mkConPars n zt ++ as
997 (TyCon s as, zt) -> checkApps (show s) [] zt (TyCon s) te (nType s) as 1004 (TyCon_ md s as, zt) -> checkApps (show s) [] zt (TyCon_ md s) te (nType s) as
998 (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]) 1005 (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])
999 (TyCaseFun s [m, t, f] n, zt) -> checkApps (show s) [] zt (\[m, t, n, f] -> evalTyCaseFun s [m, t, f] n) te (nType s) [m, t, Neut n, f] 1006 (TyCaseFun s [m, t, f] n, zt) -> checkApps (show s) [] zt (\[m, t, n, f] -> evalTyCaseFun s [m, t, f] n) te (nType s) [m, t, Neut n, f]
1000 (Neut (Fun' f vs@[] i a x), zt) -> checkApps "lab" [] zt (\xs -> Neut $ Fun' f vs i (reverse xs) x) te (nType f) $ reverse a -- TODO: recheck x 1007 (Neut (Fun_ md f vs@[] i a x), zt) -> checkApps "lab" [] zt (\xs -> Neut $ Fun_ md f vs i (reverse xs) x) te (nType f) $ reverse a -- TODO: recheck x
1001 -- TODO 1008 -- TODO
1002 (r@(Neut (Fun' f vs i a x)), zt) -> r 1009 (r@(Neut (Fun' f vs i a x)), zt) -> r
1003 (LabelEnd x, zt) -> LabelEnd $ recheck_ msg te (x, zt) 1010 (LabelEnd x, zt) -> LabelEnd $ recheck_ msg te (x, zt)
diff --git a/src/LambdaCube/Compiler/Lexer.hs b/src/LambdaCube/Compiler/Lexer.hs
index 631bbef9..83446799 100644
--- a/src/LambdaCube/Compiler/Lexer.hs
+++ b/src/LambdaCube/Compiler/Lexer.hs
@@ -87,7 +87,13 @@ instance Show Lit where
87 87
88type SName = String 88type SName = String
89 89
90pattern CaseName :: String -> String
91pattern CaseName cs <- (getCaseName -> Just cs) where CaseName = caseName
92
90caseName (c:cs) = toLower c: cs ++ "Case" 93caseName (c:cs) = toLower c: cs ++ "Case"
94getCaseName cs = case splitAt 4 $ reverse cs of
95 (reverse -> "Case", xs) -> Just $ reverse xs
96 _ -> Nothing
91 97
92pattern MatchName cs <- (getMatchName -> Just cs) where MatchName = matchName 98pattern MatchName cs <- (getMatchName -> Just cs) where MatchName = matchName
93 99
diff --git a/src/LambdaCube/Compiler/Parser.hs b/src/LambdaCube/Compiler/Parser.hs
index e4d482a8..e64327de 100644
--- a/src/LambdaCube/Compiler/Parser.hs
+++ b/src/LambdaCube/Compiler/Parser.hs
@@ -15,7 +15,7 @@ module LambdaCube.Compiler.Parser
15 , pattern SVar, pattern SType, pattern Wildcard, pattern SAppV, pattern SLamV, pattern SAnn 15 , pattern SVar, pattern SType, pattern Wildcard, pattern SAppV, pattern SLamV, pattern SAnn
16 , pattern SBuiltin, pattern SPi, pattern Primitive, pattern SLabelEnd, pattern SLam, pattern Parens 16 , pattern SBuiltin, pattern SPi, pattern Primitive, pattern SLabelEnd, pattern SLam, pattern Parens
17 , pattern TyType, pattern Wildcard_ 17 , pattern TyType, pattern Wildcard_
18 , debug, isPi, varDB, lowerDB, justDB, upDB, cmpDB, MaxDB (..), iterateN, traceD 18 , debug, isPi, varDB, lowerDB, upDB, notClosed, cmpDB, MaxDB(..), iterateN, traceD
19 , parseLC, runDefParser 19 , parseLC, runDefParser
20 , getParamsS, addParamsS, getApps, apps', downToS, addForalls 20 , getParamsS, addParamsS, getApps, apps', downToS, addForalls
21 , mkDesugarInfo, joinDesugarInfo 21 , mkDesugarInfo, joinDesugarInfo
@@ -175,28 +175,30 @@ instance SetSourceInfo (SExp' a) where
175 SGlobal (_, n) -> SGlobal (si, n) 175 SGlobal (_, n) -> SGlobal (si, n)
176 SLit _ l -> SLit si l 176 SLit _ l -> SLit si l
177 177
178-------------------------------------------------------------------------------- low-level toolbox 178-------------------------------------------------------------------------------- De-Bruijn limit
179 179
180newtype MaxDB = MaxDB {getMaxDB :: Maybe Int} 180newtype MaxDB = MaxDB {getMaxDB :: Bool} -- True: closed
181 181
182instance Monoid MaxDB where 182instance Monoid MaxDB where
183 mempty = MaxDB Nothing 183 mempty = MaxDB True
184 MaxDB a `mappend` MaxDB a' = MaxDB $ Just $ max (fromMaybe 0 a) (fromMaybe 0 a') 184 MaxDB a `mappend` MaxDB a' = MaxDB $ a && a' -- $ Just $ max (fromMaybe 0 a) (fromMaybe 0 a')
185 185
186instance Show MaxDB where show _ = "MaxDB" 186instance Show MaxDB where show _ = "MaxDB"
187 187
188varDB i = MaxDB $ Just $ i + 1 188varDB i = MaxDB False
189 189
190lowerDB (MaxDB i) = MaxDB $ (+ (- 1)) <$> i 190lowerDB = id
191justDB (MaxDB i) = MaxDB $ Just $ fromMaybe 0 i
192 191
193-- 0 means that no free variable is used 192-- 0 means that no free variable is used
194-- 1 means that only var 0 is used 193-- 1 means that only var 0 is used
195--cmpDB i e = i >= maxDB e 194--cmpDB i e = i >= maxDB e
196cmpDB _ (maxDB_ -> MaxDB x) = isNothing x 195cmpDB _ (maxDB_ -> MaxDB x) = x --isNothing x
196
197upDB n = id --(MaxDB i) = MaxDB $ (\x -> if x == 0 then x else x+n) $ i
197 198
198maxDB = max 0 . fromMaybe 0 . getMaxDB . maxDB_ 199notClosed = MaxDB False
199upDB n (MaxDB i) = MaxDB $ (\x -> if x == 0 then x else x+n) <$> i 200
201-------------------------------------------------------------------------------- low-level toolbox
200 202
201class Up a where 203class Up a where
202 up_ :: Int -> Int -> a -> a 204 up_ :: Int -> Int -> a -> a
@@ -681,7 +683,7 @@ compileGuardTree ulend lend adts t = (\x -> traceD (" ! :" ++ ppShow x) x) $ g
681 ts@(GuardNode f s _ _: _) -> case Map.lookup s (snd adts) of 683 ts@(GuardNode f s _ _: _) -> case Map.lookup s (snd adts) of
682 Nothing -> error $ "Constructor is not defined: " ++ s 684 Nothing -> error $ "Constructor is not defined: " ++ s
683 Just (Left ((casename, inum), cns)) -> 685 Just (Left ((casename, inum), cns)) ->
684 foldl SAppV (SGlobal (debugSI "compileGuardTree2", casename) `SAppV` iterateN (1 + inum) SLamV (Wildcard SType)) 686 foldl SAppV (SGlobal (debugSI "compileGuardTree2", casename) `SAppV` iterateN (1 + inum) SLamV (Wildcard (Wildcard SType)))
685 [ iterateN n SLamV $ guardTreeToCases $ Alts $ map (filterGuardTree (up n f) cn 0 n . upGT 0 n) ts 687 [ iterateN n SLamV $ guardTreeToCases $ Alts $ map (filterGuardTree (up n f) cn 0 n . upGT 0 n) ts
686 | (cn, n) <- cns 688 | (cn, n) <- cns
687 ] 689 ]
@@ -1002,8 +1004,8 @@ mkDesugarInfo ss =
1002 where 1004 where
1003 pars ty = length $ filter ((== Visible) . fst) $ fst $ getParamsS ty -- todo 1005 pars ty = length $ filter ((== Visible) . fst) $ fst $ getParamsS ty -- todo
1004 1006
1005 hackHList ("HCons", _) = ("HCons", Left (("hlistConsCase", 0), [("HCons", 2)])) 1007 hackHList ("HCons", _) = ("HCons", Left (("hlistConsCase", -1), [("HCons", 2)]))
1006 hackHList ("HNil", _) = ("HNil", Left (("hlistNilCase", 0), [("HNil", 0)])) 1008 hackHList ("HNil", _) = ("HNil", Left (("hlistNilCase", -1), [("HNil", 0)]))
1007 hackHList x = x 1009 hackHList x = x
1008 1010
1009joinDesugarInfo (fm, cm) (fm', cm') = (Map.union fm fm', Map.union cm cm') 1011joinDesugarInfo (fm, cm) (fm', cm') = (Map.union fm fm', Map.union cm cm')
diff --git a/test/UnitTests.hs b/test/UnitTests.hs
index 7b592ef6..016266d0 100644
--- a/test/UnitTests.hs
+++ b/test/UnitTests.hs
@@ -20,7 +20,7 @@ main = defaultMain $ testGroup "Compiler"
20 [ testGroup "Infer" $ concat [ 20 [ testGroup "Infer" $ concat [
21 monoidTestProperties "SI" (arbitrary :: Gen SI) 21 monoidTestProperties "SI" (arbitrary :: Gen SI)
22-- , monoidTestProperties "Infos" (arbitrary :: Gen Infos) -- list is always a monoid 22-- , monoidTestProperties "Infos" (arbitrary :: Gen Infos) -- list is always a monoid
23 , monoidTestProperties "MaxDB" (arbitrary :: Gen MaxDB) 23-- , monoidTestProperties "MaxDB" (arbitrary :: Gen MaxDB)
24 ] 24 ]
25 ] 25 ]
26 26
@@ -76,9 +76,9 @@ instance TestShow Infos where
76 testShow (Infos i) = "Infos " ++ show i 76 testShow (Infos i) = "Infos " ++ show i
77-} 77-}
78-- MaxDB 78-- MaxDB
79 79{- todo
80instance Arbitrary MaxDB where 80instance Arbitrary MaxDB where
81 arbitrary = MaxDB <$> fmap (fmap abs) arbitrary 81 arbitrary = MaxDB <$> {-fmap (fmap abs)-} arbitrary
82 shrink (MaxDB m) = map MaxDB $ shrink m 82 shrink (MaxDB m) = map MaxDB $ shrink m
83 83
84instance MonoidEq MaxDB where 84instance MonoidEq MaxDB where
@@ -90,7 +90,7 @@ instance MonoidEq MaxDB where
90 90
91instance TestShow MaxDB where 91instance TestShow MaxDB where
92 testShow (MaxDB a) = "MaxDB " ++ show a 92 testShow (MaxDB a) = "MaxDB " ++ show a
93 93-}
94----------------------------------------------------------------- Test building blocks 94----------------------------------------------------------------- Test building blocks
95 95
96class Monoid m => MonoidEq m where 96class Monoid m => MonoidEq m where
diff --git a/testdata/language-features/recursion/mutualConst.lc b/testdata/language-features/recursion/mutualConst.lc
index e8b7c8e2..c7f83f18 100644
--- a/testdata/language-features/recursion/mutualConst.lc
+++ b/testdata/language-features/recursion/mutualConst.lc
@@ -1,16 +1,9 @@
1 1
2(a, b) = (True, 'c')
3
4xy = (\x y -> ((1 :: Int): y, 1: x)) (fst xy) (snd xy) 2xy = (\x y -> ((1 :: Int): y, 1: x)) (fst xy) (snd xy)
5 3
6(x, y) = xy 4(x, y) = xy
7{-
8f x A = g x
9
10g x B = 1: x
11 5
12-} 6main = case x of
13main = a && case x of
14 1: 1: 1: _ -> True 7 1: 1: 1: _ -> True
15 8
16 9