summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/LambdaCube/Compiler/CoreToIR.hs2
-rw-r--r--src/LambdaCube/Compiler/Infer.hs84
-rw-r--r--testdata/language-features/adt/adt05.out2
3 files changed, 52 insertions, 36 deletions
diff --git a/src/LambdaCube/Compiler/CoreToIR.hs b/src/LambdaCube/Compiler/CoreToIR.hs
index d3858c95..a378815d 100644
--- a/src/LambdaCube/Compiler/CoreToIR.hs
+++ b/src/LambdaCube/Compiler/CoreToIR.hs
@@ -873,7 +873,7 @@ toExp = flip runReader [] . flip evalStateT freshTypeVars . f_
873 I.Con s n xs -> Con (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) (I.mkConPars n et ++ xs) 873 I.Con s n xs -> Con (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) (I.mkConPars n et ++ xs)
874 I.TyCon s xs -> Con (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) xs 874 I.TyCon s xs -> Con (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) xs
875 I.Fun s xs -> Fun (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) xs 875 I.Fun s xs -> Fun (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) xs
876 I.CaseFun s xs -> Fun (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) xs 876 I.CaseFun s xs n -> Fun (show s) <$> f_ (I.nType s, I.TType) <*> chain [] (I.nType s) (xs ++ [I.Neut n])
877 I.Neut (I.App_ a b) -> asks makeTE >>= \te -> do 877 I.Neut (I.App_ a b) -> asks makeTE >>= \te -> do
878 let t = I.neutType te a 878 let t = I.neutType te a
879 app' <$> f_ (I.Neut a, t) <*> (head <$> chain [] t [b]) 879 app' <$> f_ (I.Neut a, t) <*> (head <$> chain [] t [b])
diff --git a/src/LambdaCube/Compiler/Infer.hs b/src/LambdaCube/Compiler/Infer.hs
index 432b647f..bc599fda 100644
--- a/src/LambdaCube/Compiler/Infer.hs
+++ b/src/LambdaCube/Compiler/Infer.hs
@@ -62,10 +62,11 @@ data Exp
62 62
63data Neutral 63data Neutral
64 = Fun__ MaxDB FunName [Exp] 64 = Fun__ MaxDB FunName [Exp]
65 | CaseFun__ MaxDB CaseFunName [Exp] -- todo: neutral at the end 65 | CaseFun__ MaxDB CaseFunName [Exp] Neutral
66 | TyCaseFun__ MaxDB TyCaseFunName [Exp] -- todo: neutral at the end 66 | TyCaseFun__ MaxDB TyCaseFunName [Exp] -- todo: neutral at the end
67 | App__ MaxDB Neutral Exp 67 | App__ MaxDB Neutral Exp
68 | Var_ !Int -- De Bruijn variable 68 | Var_ !Int -- De Bruijn variable
69 | PMLabel_ Exp{-folded expression-} Exp{-unfolded expression-}
69 deriving (Show) 70 deriving (Show)
70 71
71data 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-} TyConName Type
@@ -99,11 +100,11 @@ infixl 2 `App`, `app_`
99infixr 1 :~> 100infixr 1 :~>
100 101
101pattern Fun_ a b <- Fun__ _ a b where Fun_ a b = Fun__ (foldMap maxDB_ b) a b 102pattern Fun_ a b <- Fun__ _ a b where Fun_ a b = Fun__ (foldMap maxDB_ b) a b
102pattern CaseFun_ a b <- CaseFun__ _ a b where CaseFun_ a b = CaseFun__ (foldMap maxDB_ b) a b 103pattern CaseFun_ a b c <- CaseFun__ _ a b c where CaseFun_ a b c = CaseFun__ (foldMap maxDB_ b <> maxDB_ c) a b c
103pattern TyCaseFun_ a b <- TyCaseFun__ _ a b where TyCaseFun_ a b = TyCaseFun__ (foldMap maxDB_ b) a b 104pattern TyCaseFun_ a b <- TyCaseFun__ _ a b where TyCaseFun_ a b = TyCaseFun__ (foldMap maxDB_ b) a b
104pattern App_ a b <- App__ _ a b where App_ a b = App__ (maxDB_ a <> maxDB_ b) a b 105pattern App_ a b <- App__ _ a b where App_ a b = App__ (maxDB_ a <> maxDB_ b) a b
105pattern Fun a b = Neut (Fun_ a b) 106pattern Fun a b = Neut (Fun_ a b)
106pattern CaseFun a b = Neut (CaseFun_ a b) 107pattern CaseFun a b c = Neut (CaseFun_ a b c)
107pattern TyCaseFun a b = Neut (TyCaseFun_ a b) 108pattern TyCaseFun a b = Neut (TyCaseFun_ a b)
108pattern App a b <- Neut (App_ (Neut -> a) b) 109pattern App a b <- Neut (App_ (Neut -> a) b)
109pattern Var a = Neut (Var_ a) 110pattern Var a = Neut (Var_ a)
@@ -195,9 +196,9 @@ getEBool (ConN "False" []) = Just False
195getEBool (ConN "True" []) = Just True 196getEBool (ConN "True" []) = Just True
196getEBool _ = Nothing 197getEBool _ = Nothing
197 198
198isCaseFun (Fun f _) = True 199isCaseFun Fun{} = True
199isCaseFun (CaseFun f _) = True 200isCaseFun CaseFun{} = True
200isCaseFun (TyCaseFun f _) = True 201isCaseFun TyCaseFun{} = True
201isCaseFun _ = False 202isCaseFun _ = False
202 203
203isCon = \case 204isCon = \case
@@ -225,11 +226,11 @@ trueExp = EBool True
225-------------------------------------------------------------------------------- label handling 226-------------------------------------------------------------------------------- label handling
226 227
227data LabelKind 228data LabelKind
228 = LabelPM -- pattern match label 229 = {-LabelPM -- pattern match label
229 | LabelFix -- fix unfold label 230 | -}LabelFix -- fix unfold label
230 deriving (Show) 231 deriving (Show)
231 232
232pattern PMLabel x y = Label LabelPM x y 233pattern PMLabel x y = Neut (PMLabel_ x y)
233pattern FixLabel x y = Label LabelFix x y 234pattern FixLabel x y = Label LabelFix x y
234 235
235data LEKind 236data LEKind
@@ -241,8 +242,8 @@ pattern LabelEnd x = LabelEnd_ LEPM x
241--pattern ClosedExp x = LabelEnd_ LEClosed x 242--pattern ClosedExp x = LabelEnd_ LEClosed x
242 243
243label LabelFix x y = FixLabel x y 244label LabelFix x y = FixLabel x y
244label LabelPM x (UL (LabelEnd y)) = y 245pmLabel x (UL (LabelEnd y)) = y
245label LabelPM x y = PMLabel x y 246pmLabel x y = PMLabel x y
246 247
247pattern UL a <- (unlabel -> a) where UL = unlabel 248pattern UL a <- (unlabel -> a) where UL = unlabel
248 249
@@ -269,7 +270,6 @@ down t x | used t x = Nothing
269 | otherwise = Just $ subst t (error "impossible: down" :: Exp) x 270 | otherwise = Just $ subst t (error "impossible: down" :: Exp) x
270 271
271instance Eq Exp where 272instance Eq Exp where
272 PMLabel a _ == PMLabel a' _ = a == a'
273 FixLabel a _ == FixLabel a' _ = a == a' 273 FixLabel a _ == FixLabel a' _ = a == a'
274 FixLabel _ a == a' = a == a' 274 FixLabel _ a == a' = a == a'
275 a == FixLabel _ a' = a == a' 275 a == FixLabel _ a' = a == a'
@@ -285,8 +285,9 @@ instance Eq Exp where
285 _ == _ = False 285 _ == _ = False
286 286
287instance Eq Neutral where 287instance Eq Neutral where
288 PMLabel_ a _ == PMLabel_ a' _ = a == a'
288 Fun_ a b == Fun_ a' b' = (a, b) == (a', b') 289 Fun_ a b == Fun_ a' b' = (a, b) == (a', b')
289 CaseFun_ a b == CaseFun_ a' b' = (a, b) == (a', b') 290 CaseFun_ a b c == CaseFun_ a' b' c' = (a, b, c) == (a', b', c')
290 TyCaseFun_ a b == TyCaseFun_ a' b' = (a, b) == (a', b') 291 TyCaseFun_ a b == TyCaseFun_ a' b' = (a, b) == (a', b')
291 App_ a b == App_ a' b' = (a, b) == (a', b') 292 App_ a b == App_ a' b' = (a, b) == (a', b')
292 Var_ a == Var_ a' = a == a' 293 Var_ a == Var_ a' = a == a'
@@ -297,8 +298,7 @@ isClosed (maxDB_ -> MaxDB x) = isNothing x
297-- 0 means that no free variable is used 298-- 0 means that no free variable is used
298-- 1 means that only var 0 is used 299-- 1 means that only var 0 is used
299maxDB = max 0 . fromMaybe 0 . getMaxDB . maxDB_ 300maxDB = max 0 . fromMaybe 0 . getMaxDB . maxDB_
300upDB n x@(MaxDB 0) = x 301upDB n (MaxDB i) = MaxDB $ (\x -> if x == 0 then x else x+n) <$> i
301upDB n (MaxDB i) = MaxDB $ (+n) <$> i
302 302
303free x | isClosed x = mempty 303free x | isClosed x = mempty
304free x = fold (\i k -> Set.fromList [k - i | k >= i]) 0 x 304free x = fold (\i k -> Set.fromList [k - i | k >= i]) 0 x
@@ -321,7 +321,6 @@ instance Up Exp where
321 | otherwise = ((getAny .) . fold ((Any .) . (==))) i e 321 | otherwise = ((getAny .) . fold ((Any .) . (==))) i e
322 322
323 fold f i = \case 323 fold f i = \case
324 PMLabel x _ -> fold f i x
325 FixLabel _ x -> fold f i x 324 FixLabel _ x -> fold f i x
326 Lam b -> {-fold f i t <> todo: explain why this is not needed -} fold f (i+1) b 325 Lam b -> {-fold f i t <> todo: explain why this is not needed -} fold f (i+1) b
327 Pi _ a b -> fold f i a <> fold f (i+1) b 326 Pi _ a b -> fold f i a <> fold f (i+1) b
@@ -339,7 +338,6 @@ instance Up Exp where
339 TyCon_ c _ _ -> c 338 TyCon_ c _ _ -> c
340 339
341 Neut x -> maxDB_ x 340 Neut x -> maxDB_ x
342 PMLabel x y -> maxDB_ x -- `combineDB` maxDB_ y
343 FixLabel x y -> maxDB_ x <> maxDB_ y 341 FixLabel x y -> maxDB_ x <> maxDB_ y
344 TType -> mempty 342 TType -> mempty
345 ELit _ -> mempty 343 ELit _ -> mempty
@@ -351,6 +349,8 @@ instance Up Exp where
351 Con_ _ a b c -> Con_ mempty a b c 349 Con_ _ a b c -> Con_ mempty a b c
352 TyCon_ _ a b -> TyCon_ mempty a b 350 TyCon_ _ a b -> TyCon_ mempty a b
353 Neut a -> Neut $ closedExp a 351 Neut a -> Neut $ closedExp a
352 Label lk a b -> Label lk (closedExp a) (closedExp b)
353 LabelEnd a -> LabelEnd (closedExp a)
354 e -> e 354 e -> e
355 355
356instance Subst Exp Exp where 356instance Subst Exp Exp where
@@ -362,9 +362,10 @@ instance Subst Exp Exp where
362 substNeut e = case e of 362 substNeut e = case e of
363 Var_ k -> case compare k i of GT -> Var $ k - 1; LT -> Var k; EQ -> up (i - i0) x 363 Var_ k -> case compare k i of GT -> Var $ k - 1; LT -> Var k; EQ -> up (i - i0) x
364 Fun_ s as -> eval $ Fun s $ f i <$> as 364 Fun_ s as -> eval $ Fun s $ f i <$> as
365 CaseFun_ s as -> eval $ CaseFun s $ f i <$> as 365 CaseFun_ s as n -> evalCaseFun s (f i <$> as) (substNeut n)
366 TyCaseFun_ s as -> eval $ TyCaseFun s $ f i <$> as 366 TyCaseFun_ s as -> eval $ TyCaseFun s $ f i <$> as
367 App_ a b -> app_ (substNeut a) (f i b) 367 App_ a b -> app_ (substNeut a) (f i b)
368 PMLabel_ z v -> pmLabel (f i z) $ f i v
368 f i e | {-i >= maxDB e-} isClosed e = e 369 f i e | {-i >= maxDB e-} isClosed e = e
369 f i e = case e of 370 f i e = case e of
370 Label lk z v -> label lk (f i z) $ f i v 371 Label lk z v -> label lk (f i z) $ f i v
@@ -381,9 +382,10 @@ instance Up Neutral where
381 f i e = case e of 382 f i e = case e of
382 Var_ k -> Var_ $ if k >= i then k+n else k 383 Var_ k -> Var_ $ if k >= i then k+n else k
383 Fun__ md s as -> Fun__ (upDB n md) s $ map (up_ n i) as 384 Fun__ md s as -> Fun__ (upDB n md) s $ map (up_ n i) as
384 CaseFun__ md s as -> CaseFun__ (upDB n md) s $ map (up_ n i) as 385 CaseFun__ md s as ne -> CaseFun__ (upDB n md) s (up_ n i <$> as) (up_ n i ne)
385 TyCaseFun__ md s as -> TyCaseFun__ (upDB n md) s $ map (up_ n i) as 386 TyCaseFun__ md s as -> TyCaseFun__ (upDB n md) s $ map (up_ n i) as
386 App__ md a b -> App__ (upDB n md) (up_ n i a) (up_ n i b) 387 App__ md a b -> App__ (upDB n md) (up_ n i a) (up_ n i b)
388 PMLabel_ x y -> PMLabel_ (up_ n i x) $ up_ n i y
387 389
388 used i e 390 used i e
389 | i >= maxDB e = False 391 | i >= maxDB e = False
@@ -392,23 +394,26 @@ instance Up Neutral where
392 fold f i = \case 394 fold f i = \case
393 Var_ k -> f i k 395 Var_ k -> f i k
394 Fun_ _ as -> foldMap (fold f i) as 396 Fun_ _ as -> foldMap (fold f i) as
395 CaseFun_ _ as -> foldMap (fold f i) as 397 CaseFun_ _ as n -> foldMap (fold f i) as <> fold f i n
396 TyCaseFun_ _ as -> foldMap (fold f i) as 398 TyCaseFun_ _ as -> foldMap (fold f i) as
397 App_ a b -> fold f i a <> fold f i b 399 App_ a b -> fold f i a <> fold f i b
400 PMLabel_ x _ -> fold f i x
398 401
399 maxDB_ = \case 402 maxDB_ = \case
400 Var_ k -> varDB k 403 Var_ k -> varDB k
401 Fun__ c _ as -> c 404 Fun__ c _ _ -> c
402 CaseFun__ c _ as -> c 405 CaseFun__ c _ _ _ -> c
403 TyCaseFun__ c _ as -> c 406 TyCaseFun__ c _ _ -> c
404 App__ c a b -> c 407 App__ c a b -> c
408 PMLabel_ x y -> maxDB_ x
405 409
406 closedExp = \case 410 closedExp = \case
407 x@Var_{} -> error "impossible" 411 x@Var_{} -> error "impossible"
408 Fun__ _ a as -> Fun__ mempty a as 412 Fun__ _ a as -> Fun__ mempty a as
409 CaseFun__ _ a as -> CaseFun__ mempty a as 413 CaseFun__ _ a as n -> CaseFun__ mempty a as n
410 TyCaseFun__ _ a as -> TyCaseFun__ mempty a as 414 TyCaseFun__ _ a as -> TyCaseFun__ mempty a as
411 App__ _ a b -> App__ mempty a b 415 App__ _ a b -> App__ mempty a b
416 PMLabel_ x y -> PMLabel_ (closedExp x) (closedExp y)
412 417
413instance (Subst x a, Subst x b) => Subst x (a, b) where 418instance (Subst x a, Subst x b) => Subst x (a, b) where
414 subst i x (a, b) = (subst i x a, subst i x b) 419 subst i x (a, b) = (subst i x a, subst i x b)
@@ -422,6 +427,14 @@ varType err n_ env = f n_ env where
422 427
423-------------------------------------------------------------------------------- reduction 428-------------------------------------------------------------------------------- reduction
424 429
430evalCaseFun (CaseFunName _ t pars) (drop (pars + 1) -> ps) (Con (ConName _ _ i _ _) _ vs)
431 | i /= (-1) = foldl app_ (ps !! i) vs
432 | otherwise = error "evcf"
433evalCaseFun a b (Neut c) = CaseFun a b c
434evalCaseFun a b (FixLabel _ c) = evalCaseFun a b c
435--evalCaseFun a b (Label _ _ _) = error $ "e cf: " ++ show a -- ++ "\n" ++ show x
436--evalCaseFun a b x = error $ "ecf: " ++ show a -- ++ "\n" ++ show x
437
425eval = \case 438eval = \case
426 App a b -> app_ a b 439 App a b -> app_ a b
427 CstrT TType a b -> cstrT_ TType a b 440 CstrT TType a b -> cstrT_ TType a b
@@ -429,8 +442,6 @@ eval = \case
429 ReflCstr a -> reflCstr a 442 ReflCstr a -> reflCstr a
430 Coe a b TT d -> d 443 Coe a b TT d -> d
431 444
432 CaseFun (CaseFunName _ t pars) (drop (pars + 1) -> ps@(last -> UL (Con (ConName _ _ i _ _) _ vs))) | i /= (-1) -> foldl app_ (ps !! i) vs
433
434 TyCaseFun (TyCaseFunName n ty) [_, t, UL (TyCon (TyConName n' _ _ _ _ _) vs), f] | n == n' -> foldl app_ t vs 445 TyCaseFun (TyCaseFunName n ty) [_, t, UL (TyCon (TyConName n' _ _ _ _ _) vs), f] | n == n' -> foldl app_ t vs
435 TyCaseFun (TyCaseFunName n ty) [_, t, LCon, f] -> f 446 TyCaseFun (TyCaseFunName n ty) [_, t, LCon, f] -> f
436 T2 a b -> t2 a b 447 T2 a b -> t2 a b
@@ -631,7 +642,11 @@ app_ (Con s n xs) a = if n < conParams s then Con s (n+1) xs else Con s n (xs ++
631app_ (TyCon s xs) a = TyCon s (xs ++ [a]) 642app_ (TyCon s xs) a = TyCon s (xs ++ [a])
632app_ (Label lk x e) a = label lk (app_ x a) $ app_ e a 643app_ (Label lk x e) a = label lk (app_ x a) $ app_ e a
633app_ (LabelEnd_ k x) a = LabelEnd_ k (app_ x a) -- ??? 644app_ (LabelEnd_ k x) a = LabelEnd_ k (app_ x a) -- ???
634app_ (Neut f) a = Neut $ App_ f a 645app_ (PMLabel x e) a = pmLabel (app_ x a) $ app_ e a
646app_ (Neut f) a = Neut $ App_ f a --neutApp f a
647
648--neutApp (PMLabel_ x e) a = pmLabel (app_ x a) (app_ e a)
649--neutApp f a = App_ f a
635 650
636-------------------------------------------------------------------------------- constraints env 651-------------------------------------------------------------------------------- constraints env
637 652
@@ -733,7 +748,7 @@ neutType te = \case
733 App_ f x -> appTy (neutType te f) x 748 App_ f x -> appTy (neutType te f) x
734 Var_ i -> snd $ varType "C" i te 749 Var_ i -> snd $ varType "C" i te
735 Fun_ s ts -> foldl appTy (nType s) ts 750 Fun_ s ts -> foldl appTy (nType s) ts
736 CaseFun_ s ts -> foldl appTy (nType s) ts 751 CaseFun_ s ts n -> appTy (foldl appTy (nType s) ts) (Neut n)
737 TyCaseFun_ s ts -> foldl appTy (nType s) ts 752 TyCaseFun_ s ts -> foldl appTy (nType s) ts
738 753
739appTy (Pi _ a b) x = subst 0 x b 754appTy (Pi _ a b) x = subst 0 x b
@@ -981,12 +996,13 @@ recheck' msg' e (x, xt) = (recheck_ "main" (checkEnv e) (x, xt), xt)
981 (Neut (App_ a b), zt) 996 (Neut (App_ a b), zt)
982 | (Neut a', at) <- recheck'' "app1" te (Neut a, neutType te a) 997 | (Neut a', at) <- recheck'' "app1" te (Neut a, neutType te a)
983 -> checkApps [] zt (Neut . App_ a' . head) te at [b] 998 -> checkApps [] zt (Neut . App_ a' . head) te at [b]
984 (Con s n as, zt) -> checkApps [] zt (Con s n . drop (conParams s)) te (nType s) $ mkConPars n zt ++ as 999 (Con s n as, zt) -> checkApps [] zt (Con s n . drop (conParams s)) te (nType s) $ mkConPars n zt ++ as
985 (TyCon s as, zt) -> checkApps [] zt (TyCon s) te (nType s) as 1000 (TyCon s as, zt) -> checkApps [] zt (TyCon s) te (nType s) as
986 (Fun s as, zt) -> checkApps [] zt (Fun s) te (nType s) as 1001 (Fun s as, zt) -> checkApps [] zt (Fun s) te (nType s) as
987 (CaseFun s as, zt) -> checkApps [] zt (CaseFun s) te (nType s) as 1002 (CaseFun s as n, zt) -> checkApps [] zt (\xs -> evalCaseFun s (init xs) (last xs)) te (nType s) (as ++ [Neut n])
988 (TyCaseFun s as, zt) -> checkApps [] zt (TyCaseFun s) te (nType s) as 1003 (TyCaseFun s as, zt) -> checkApps [] zt (TyCaseFun s) te (nType s) as
989 (Label lk a x, zt) -> Label lk (recheck_ msg te (a, zt)) x 1004 (Label lk a x, zt) -> Label lk (recheck_ msg te (a, zt)) x
1005 (PMLabel a x, zt) -> PMLabel (recheck_ msg te (a, zt)) x
990 (LabelEnd_ k x, zt) -> LabelEnd_ k $ recheck_ msg te (x, zt) 1006 (LabelEnd_ k x, zt) -> LabelEnd_ k $ recheck_ msg te (x, zt)
991 where 1007 where
992 checkApps acc zt f _ t [] | t == zt = f $ reverse acc 1008 checkApps acc zt f _ t [] | t == zt = f $ reverse acc
@@ -1154,7 +1170,7 @@ handleStmt defs = \case
1154 ) 1170 )
1155 $ foldl SAppV (SVar (debugSI "23", ".ct") $ length cs + inum + 1) $ downToS 1 inum ++ [SVar (debugSI "24", ".24") 0] 1171 $ foldl SAppV (SVar (debugSI "23", ".ct") $ length cs + inum + 1) $ downToS 1 inum ++ [SVar (debugSI "24", ".24") 0]
1156 ) 1172 )
1157 addToEnv (fst s, caseName (snd s)) (lamify ct $ CaseFun cfn, ct) 1173 addToEnv (fst s, caseName (snd s)) (lamify ct $ \xs -> evalCaseFun cfn (init xs) (last xs), ct)
1158 let ps' = fst $ getParams vty 1174 let ps' = fst $ getParams vty
1159 t = (TType :~> TType) 1175 t = (TType :~> TType)
1160 :~> addParams ps' (Var (length ps') `app_` TyCon tcn (downTo 0 $ length ps')) 1176 :~> addParams ps' (Var (length ps') `app_` TyCon tcn (downTo 0 $ length ps'))
@@ -1168,7 +1184,7 @@ handleStmt defs = \case
1168mkELet (False, n, mf, ar) x xt = x 1184mkELet (False, n, mf, ar) x xt = x
1169mkELet (True, n, SData mf, ar) x t{-type of x-} = term 1185mkELet (True, n, SData mf, ar) x t{-type of x-} = term
1170 where 1186 where
1171 term = label LabelPM (addLams' ar t 0) $ par ar t x 0 1187 term = pmLabel (addLams' ar t 0) $ par ar t x 0
1172 1188
1173 addLams' [] _ i = Fun (FunName (snd n) mf t) $ downTo 0 i 1189 addLams' [] _ i = Fun (FunName (snd n) mf t) $ downTo 0 i
1174 addLams' (h: ar) (Pi h' d t) i | h == h' = Lam $ addLams' ar t (i+1) 1190 addLams' (h: ar) (Pi h' d t) i | h == h' = Lam $ addLams' ar t (i+1)
@@ -1331,7 +1347,6 @@ instance MkDoc Exp where
1331 mkDoc ts e = fmap inGreen <$> f e 1347 mkDoc ts e = fmap inGreen <$> f e
1332 where 1348 where
1333 f = \case 1349 f = \case
1334 PMLabel x _ -> f x
1335 FixLabel _ x -> f x 1350 FixLabel _ x -> f x
1336 Neut x -> mkDoc ts x 1351 Neut x -> mkDoc ts x
1337-- Lam h a b -> join $ shLam (used 0 b) (BLam h) <$> f a <*> pure (f b) 1352-- Lam h a b -> join $ shLam (used 0 b) (BLam h) <$> f a <*> pure (f b)
@@ -1351,11 +1366,12 @@ instance MkDoc Neutral where
1351 where 1366 where
1352 g = mkDoc ts 1367 g = mkDoc ts
1353 f = \case 1368 f = \case
1369 PMLabel_ x _ -> g x
1354 Var_ k -> shAtom <$> shVar k 1370 Var_ k -> shAtom <$> shVar k
1355 App_ a b -> shApp Visible <$> g a <*> g b 1371 App_ a b -> shApp Visible <$> g a <*> g b
1356 CstrT' TType a b -> shCstr <$> g a <*> g b 1372 CstrT' TType a b -> shCstr <$> g a <*> g b
1357 Fun_ s xs -> foldl (shApp Visible) (shAtom_ $ show s) <$> mapM g xs 1373 Fun_ s xs -> foldl (shApp Visible) (shAtom_ $ show s) <$> mapM g xs
1358 CaseFun_ s xs -> foldl (shApp Visible) (shAtom_ $ show s) <$> mapM g xs 1374 CaseFun_ s xs n -> foldl (shApp Visible) (shAtom_ $ show s) <$> mapM g (xs ++ [Neut n])
1359 TyCaseFun_ s xs -> foldl (shApp Visible) (shAtom_ $ show s) <$> mapM g xs 1375 TyCaseFun_ s xs -> foldl (shApp Visible) (shAtom_ $ show s) <$> mapM g xs
1360 1376
1361 shAtom_ = shAtom . if ts then switchTick else id 1377 shAtom_ = shAtom . if ts then switchTick else id
diff --git a/testdata/language-features/adt/adt05.out b/testdata/language-features/adt/adt05.out
index 97b40b5c..29167f4f 100644
--- a/testdata/language-features/adt/adt05.out
+++ b/testdata/language-features/adt/adt05.out
@@ -1 +1 @@
main \ No newline at end of file main \ No newline at end of file