summaryrefslogtreecommitdiff
path: root/src/LambdaCube/Compiler/Infer.hs
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-04-28 22:43:51 +0200
committerPéter Diviánszky <divipp@gmail.com>2016-04-28 22:43:51 +0200
commit67fd4cabceda047750c19e9bef98e0c25c6ed7dd (patch)
treee64ac6cd1de2583e13f386421b952f32ffb8f955 /src/LambdaCube/Compiler/Infer.hs
parent56f6e4fb7b8c0fc6545843d467412fbfa8acb277 (diff)
switch to Haskell style syntax in pretty print
Diffstat (limited to 'src/LambdaCube/Compiler/Infer.hs')
-rw-r--r--src/LambdaCube/Compiler/Infer.hs43
1 files changed, 4 insertions, 39 deletions
diff --git a/src/LambdaCube/Compiler/Infer.hs b/src/LambdaCube/Compiler/Infer.hs
index e00bcb47..74e0c4d6 100644
--- a/src/LambdaCube/Compiler/Infer.hs
+++ b/src/LambdaCube/Compiler/Infer.hs
@@ -1447,7 +1447,7 @@ tellType si t = tell $ mkInfoItem (sourceInfo si) $ plainShow $ mkDoc False True
1447 1447
1448 1448
1449-------------------------------------------------------------------------------- pretty print 1449-------------------------------------------------------------------------------- pretty print
1450-- todo: do this via conversion to SExp 1450-- todo: do this via conversion to SExp?
1451 1451
1452instance PShow Exp where 1452instance PShow Exp where
1453 pShow = mkDoc False False 1453 pShow = mkDoc False False
@@ -1465,43 +1465,8 @@ showEnvSExp :: Up a => Env -> SExp' a -> String
1465showEnvSExp e c = show $ envDoc e $ underline $ sExpDoc c 1465showEnvSExp e c = show $ envDoc e $ underline $ sExpDoc c
1466 1466
1467showEnvSExpType :: Up a => Env -> SExp' a -> Exp -> String 1467showEnvSExpType :: Up a => Env -> SExp' a -> Exp -> String
1468showEnvSExpType e c t = show $ envDoc e $ underline $ (shAnn "::" False (sExpDoc c) (mkDoc False False (t, TType))) 1468showEnvSExpType e c t = show $ envDoc e $ underline $ (shAnn False (sExpDoc c) (mkDoc False False (t, TType)))
1469{-
1470 where
1471 infixl 4 <**>
1472 (<**>) :: NameDB (a -> b) -> NameDB a -> NameDB b
1473 a <**> b = get >>= \s -> lift $ evalStateT a s <*> evalStateT b s
1474-}
1475 1469
1476{-
1477expToSExp :: Exp -> SExp
1478expToSExp = \case
1479 Fun x _ -> expToSExp x
1480-- Var k -> text <$> shVar k
1481 App a b -> SApp Visible{-todo-} (expToSExp a) (expToSExp b)
1482{-
1483 Lam h a b -> join $ shLam (usedVar 0 b) (BLam h) <$> f a <*> pure (f b)
1484 Bind h a b -> join $ shLam (usedVar 0 b) h <$> f a <*> pure (f b)
1485 Cstr a b -> shCstr <$> f a <*> f b
1486 MT s xs -> foldl (shApp Visible) (text s) <$> mapM f xs
1487 CaseFun s xs -> foldl (shApp Visible) (text $ show s) <$> mapM f xs
1488 TyCaseFun s xs -> foldl (shApp Visible) (text $ show s) <$> mapM f xs
1489 ConN s xs -> foldl (shApp Visible) (text s) <$> mapM f xs
1490 TyConN s xs -> foldl (shApp Visible) (text s) <$> mapM f xs
1491-- TType -> pure $ text "Type"
1492 ELit l -> pure $ text $ show l
1493 Assign i x e -> shLet i (f x) (f e)
1494 LabelEnd x -> shApp Visible (text "labend") <$> f x
1495-}
1496nameSExp :: SExp -> NameDB SExp
1497nameSExp = \case
1498 SGlobal s -> pure $ SGlobal s
1499 SApp h a b -> SApp h <$> nameSExp a <*> nameSExp b
1500 SBind h a b -> newName >>= \n -> SBind h <$> nameSExp a <*> local (n:) (nameSExp b)
1501 SLet a b -> newName >>= \n -> SLet <$> nameSExp a <*> local (n:) (nameSExp b)
1502 STyped_ (e, _) -> nameSExp $ expToSExp e -- todo: mark boundary
1503 SVar i -> SGlobal <$> shVar i
1504-}
1505envDoc :: Env -> Doc -> Doc 1470envDoc :: Env -> Doc -> Doc
1506envDoc x m = case x of 1471envDoc x m = case x of
1507 EGlobal{} -> m 1472 EGlobal{} -> m
@@ -1513,8 +1478,8 @@ envDoc x m = case x of
1513 ELet1 _ ts b -> envDoc ts $ shLet_ m (sExpDoc b) 1478 ELet1 _ ts b -> envDoc ts $ shLet_ m (sExpDoc b)
1514 ELet2 _ x ts -> envDoc ts $ shLet_ (mkDoc False ts' x) m 1479 ELet2 _ x ts -> envDoc ts $ shLet_ (mkDoc False ts' x) m
1515 EAssign i x ts -> envDoc ts $ shLet i (mkDoc False ts' x) m 1480 EAssign i x ts -> envDoc ts $ shLet i (mkDoc False ts' x) m
1516 CheckType t ts -> envDoc ts $ shAnn ":" False m $ mkDoc False ts' (t, TType) 1481 CheckType t ts -> envDoc ts $ shAnn False m $ mkDoc False ts' (t, TType)
1517 CheckIType t ts -> envDoc ts $ shAnn ":" False m (text "??") -- mkDoc ts' t 1482 CheckIType t ts -> envDoc ts $ shAnn False m (text "??") -- mkDoc ts' t
1518-- CheckSame t ts -> envDoc ts $ shCstr <$> m <*> mkDoc ts' t 1483-- CheckSame t ts -> envDoc ts $ shCstr <$> m <*> mkDoc ts' t
1519 CheckAppType si h t te b -> envDoc (EApp1 si h (CheckType_ (sourceInfo b) t te) b) m 1484 CheckAppType si h t te b -> envDoc (EApp1 si h (CheckType_ (sourceInfo b) t te) b) m
1520 ELabelEnd ts -> envDoc ts $ shApp Visible (text "labEnd") m 1485 ELabelEnd ts -> envDoc ts $ shApp Visible (text "labEnd") m