diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-05-01 22:56:42 +0200 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-05-01 22:56:42 +0200 |
commit | 128cf82881352cc1e9061db97fe3762315cfd0c9 (patch) | |
tree | 60f0efc4d587a58359b39edba470fd55a0d8c69a /src/LambdaCube/Compiler/Infer.hs | |
parent | e2ef3e4de33e15627ce21c7c506650b2f8123a1c (diff) |
removing coloring from .out files
Diffstat (limited to 'src/LambdaCube/Compiler/Infer.hs')
-rw-r--r-- | src/LambdaCube/Compiler/Infer.hs | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/LambdaCube/Compiler/Infer.hs b/src/LambdaCube/Compiler/Infer.hs index 61a50814..1b747e69 100644 --- a/src/LambdaCube/Compiler/Infer.hs +++ b/src/LambdaCube/Compiler/Infer.hs | |||
@@ -952,10 +952,10 @@ inferN_ tellTrace = infer where | |||
952 | Parens x -> infer te x | 952 | Parens x -> infer te x |
953 | SAnn x t -> checkN (CheckIType x te) t TType | 953 | SAnn x t -> checkN (CheckIType x te) t TType |
954 | SRHS x -> infer (ELabelEnd te) x | 954 | SRHS x -> infer (ELabelEnd te) x |
955 | SVar sn i -> focus_' te exp (Var i, snd $ varType "C2" i te) | 955 | SVar sn i -> focusTell te exp (Var i, snd $ varType "C2" i te) |
956 | SLit si l -> focus_' te exp (ELit l, litType l) | 956 | SLit si l -> focusTell te exp (ELit l, litType l) |
957 | STyped et -> focus_' te exp et | 957 | STyped et -> focusTell' te exp et |
958 | SGlobal (SIName si s) -> focus_' te exp =<< getDef te si s | 958 | SGlobal (SIName si s) -> focusTell te exp =<< getDef te si s |
959 | SLet le a b -> infer (ELet1 le te b{-in-}) a{-let-} -- infer te SLamV b `SAppV` a) | 959 | SLet le a b -> infer (ELet1 le te b{-in-}) a{-let-} -- infer te SLamV b `SAppV` a) |
960 | SApp_ si h a b -> infer (EApp1 (si `validate` [sourceInfo a, sourceInfo b]) h te b) a | 960 | SApp_ si h a b -> infer (EApp1 (si `validate` [sourceInfo a, sourceInfo b]) h te b) a |
961 | SBind_ si h _ a b -> infer ((if h /= BMeta then CheckType_ (sourceInfo exp) TType else id) $ EBind1 si h te $ (if isPi h then TyType else id) b) a | 961 | SBind_ si h _ a b -> infer ((if h /= BMeta then CheckType_ (sourceInfo exp) TType else id) $ EBind1 si h te $ (if isPi h then TyType else id) b) a |
@@ -984,7 +984,7 @@ inferN_ tellTrace = infer where | |||
984 | | SRHS x <- e = checkN (ELabelEnd te) x t | 984 | | SRHS x <- e = checkN (ELabelEnd te) x t |
985 | | SApp_ si h a b <- e = infer (CheckAppType si h t te b) a | 985 | | SApp_ si h a b <- e = infer (CheckAppType si h t te b) a |
986 | | SLam h a b <- e, Pi h' x y <- t, h == h' = do | 986 | | SLam h a b <- e, Pi h' x y <- t, h == h' = do |
987 | tellType e t | 987 | -- tellType e t |
988 | let same = checkSame te a x | 988 | let same = checkSame te a x |
989 | if same then checkN (EBind2 (BLam h) x te) b y else error $ "checkSame:\n" ++ ppShow a ++ "\nwith\n" ++ showEnvExp te (x, TType) | 989 | if same then checkN (EBind2 (BLam h) x te) b y else error $ "checkSame:\n" ++ ppShow a ++ "\nwith\n" ++ showEnvExp te (x, TType) |
990 | | Pi Hidden a b <- t = do | 990 | | Pi Hidden a b <- t = do |
@@ -1018,7 +1018,8 @@ inferN_ tellTrace = infer where | |||
1018 | hArgs (Pi Hidden _ b) = 1 + hArgs b | 1018 | hArgs (Pi Hidden _ b) = 1 + hArgs b |
1019 | hArgs _ = 0 | 1019 | hArgs _ = 0 |
1020 | 1020 | ||
1021 | focus_' env si eet = tellType si (snd eet) >> focus_ env eet | 1021 | focusTell env si eet = tellType si (snd eet) >> focus_ env eet |
1022 | focusTell' env si eet = focus_ env eet | ||
1022 | 1023 | ||
1023 | focus_ :: Env -> ExpType -> IM m ExpType' | 1024 | focus_ :: Env -> ExpType -> IM m ExpType' |
1024 | focus_ env eet@(e, et) = tellTrace "focus" (showEnvExp env eet) $ case env of | 1025 | focus_ env eet@(e, et) = tellTrace "focus" (showEnvExp env eet) $ case env of |
@@ -1045,10 +1046,10 @@ inferN_ tellTrace = infer where | |||
1045 | | hArgs et < hArgs t, Pi Hidden t1 t2 <- t | 1046 | | hArgs et < hArgs t, Pi Hidden t1 t2 <- t |
1046 | -> focus_ (CheckType_ si t2 $ EBind2 (BLam Hidden) t1 te) eet | 1047 | -> focus_ (CheckType_ si t2 $ EBind2 (BLam Hidden) t1 te) eet |
1047 | | otherwise -> focus_ (EBind2_ si BMeta (cstr TType t et) te) $ up 1 eet | 1048 | | otherwise -> focus_ (EBind2_ si BMeta (cstr TType t et) te) $ up 1 eet |
1048 | EApp2 si h (a, at) te -> focus_' te si (app_ a e, appTy at e) -- h?? | 1049 | EApp2 si h (a, at) te -> focusTell te si (app_ a e, appTy at e) -- h?? |
1049 | EBind1 si h te b -> infer (EBind2_ (sourceInfo b) h e te) b | 1050 | EBind1 si h te b -> infer (EBind2_ (sourceInfo b) h e te) b |
1050 | EBind2_ si (BLam h) a te -> focus_ te $ lamPi h a eet | 1051 | EBind2_ si (BLam h) a te -> focus_ te $ lamPi h a eet |
1051 | EBind2_ si (BPi h) a te -> focus_' te si (Pi h a e, TType) | 1052 | EBind2_ si (BPi h) a te -> focusTell te si (Pi h a e, TType) |
1052 | _ -> focus2 env $ MEnd eet | 1053 | _ -> focus2 env $ MEnd eet |
1053 | 1054 | ||
1054 | focus2 :: Env -> CEnv ExpType -> IM m ExpType' | 1055 | focus2 :: Env -> CEnv ExpType -> IM m ExpType' |
@@ -1065,8 +1066,8 @@ inferN_ tellTrace = infer where | |||
1065 | | CstrT t a b <- tt, Just r <- cst (b, t) a -> r | 1066 | | CstrT t a b <- tt, Just r <- cst (b, t) a -> r |
1066 | | isCstr tt, EBind2 h x te' <- te{-, h /= BMeta todo: remove-}, Just x' <- down 0 tt, x == x' | 1067 | | isCstr tt, EBind2 h x te' <- te{-, h /= BMeta todo: remove-}, Just x' <- down 0 tt, x == x' |
1067 | -> refocus te $ subst 1 (Var 0) eet | 1068 | -> refocus te $ subst 1 (Var 0) eet |
1068 | | EBind2 h x te' <- te, h /= BMeta, Just b' <- down 0 tt | 1069 | | EBind2_ si' h x te' <- te, h /= BMeta, Just b' <- down 0 tt |
1069 | -> refocus (EBind2_ si h (up 1 x) $ EBind2_ si BMeta b' te') $ subst 2 (Var 0) $ up 1 eet | 1070 | -> refocus (EBind2_ si' h (up 1 x) $ EBind2_ si BMeta b' te') $ subst 2 (Var 0) $ up 1 eet |
1070 | | ELet2 le (x, xt) te' <- te, Just b' <- down 0 tt | 1071 | | ELet2 le (x, xt) te' <- te, Just b' <- down 0 tt |
1071 | -> refocus (ELet2 le (up 1 x, up 1 xt) $ EBind2_ si BMeta b' te') $ subst 2 (Var 0) $ up 1 eet | 1072 | -> refocus (ELet2 le (up 1 x, up 1 xt) $ EBind2_ si BMeta b' te') $ subst 2 (Var 0) $ up 1 eet |
1072 | | EBind1 si h te' x <- te -> refocus (EBind1 si h (EBind2_ si BMeta tt_ te') $ up1_ 1 x) eet | 1073 | | EBind1 si h te' x <- te -> refocus (EBind1 si h (EBind2_ si BMeta tt_ te') $ up1_ 1 x) eet |
@@ -1261,7 +1262,7 @@ initEnv = Map.fromList | |||
1261 | -------------------------------------------------------------------------------- infos | 1262 | -------------------------------------------------------------------------------- infos |
1262 | 1263 | ||
1263 | data Info | 1264 | data Info |
1264 | = Info Range String | 1265 | = Info Range Doc |
1265 | | IType SIName Exp | 1266 | | IType SIName Exp |
1266 | | ITrace String String | 1267 | | ITrace String String |
1267 | | IError ErrorMsg | 1268 | | IError ErrorMsg |
@@ -1279,7 +1280,7 @@ instance NFData Info where rnf = rnf . ppShow | |||
1279 | -} | 1280 | -} |
1280 | instance PShow Info where | 1281 | instance PShow Info where |
1281 | pShow = \case | 1282 | pShow = \case |
1282 | Info r s -> shortForm (pShow r) <+> "" <+> text s | 1283 | Info r s -> nest 4 $ shortForm (pShow r) <$$> s |
1283 | IType a b -> shAnn (pShow a) (pShow b) | 1284 | IType a b -> shAnn (pShow a) (pShow b) |
1284 | ITrace i s -> text i <> ": " <+> text s | 1285 | ITrace i s -> text i <> ": " <+> text s |
1285 | IError e -> "!" <> pShow e | 1286 | IError e -> "!" <> pShow e |
@@ -1295,14 +1296,14 @@ mkInfoItem (RangeSI r) i = [Info r i] | |||
1295 | mkInfoItem _ _ = mempty | 1296 | mkInfoItem _ _ = mempty |
1296 | 1297 | ||
1297 | listAllInfos m = h "trace" (listTraceInfos m) | 1298 | listAllInfos m = h "trace" (listTraceInfos m) |
1298 | ++ h "tooltips" [ show (shortForm $ pShow r) ++ " " ++ intercalate " | " is | (r, is) <- listTypeInfos m ] | 1299 | ++ h "tooltips" [ nest 4 $ shortForm (pShow r) <$$> hsep (intersperse "|" is) | (r, is) <- listTypeInfos m ] |
1299 | ++ h "warnings" [ ppShow w | ParseWarning w <- m ] | 1300 | ++ h "warnings" [ pShow w | ParseWarning w <- m ] |
1300 | where | 1301 | where |
1301 | h x [] = [] | 1302 | h x [] = [] |
1302 | h x xs = ("------------ " ++ x) : xs | 1303 | h x xs = ("------------" <+> x) : xs |
1303 | 1304 | ||
1304 | listTraceInfos m = [ppShow i | i <- m, case i of Info{} -> False; ParseWarning{} -> False; _ -> True] | 1305 | listTraceInfos m = [DResetFreshNames $ pShow i | i <- m, case i of Info{} -> False; ParseWarning{} -> False; _ -> True] |
1305 | listTypeInfos m = map (second Set.toList) $ Map.toList $ Map.unionsWith (<>) [Map.singleton r $ Set.singleton i | Info r i <- m] | 1306 | listTypeInfos m = Map.toList $ Map.unionsWith (<>) [Map.singleton r [i] | Info r i <- m] |
1306 | 1307 | ||
1307 | -------------------------------------------------------------------------------- inference for statements | 1308 | -------------------------------------------------------------------------------- inference for statements |
1308 | 1309 | ||
@@ -1346,7 +1347,7 @@ handleStmt = \case | |||
1346 | | c == SGlobal s && take pnum' xs == downToS "a3" (length ctl) pnum' | 1347 | | c == SGlobal s && take pnum' xs == downToS "a3" (length ctl) pnum' |
1347 | = do | 1348 | = do |
1348 | cty <- removeHiddenUnit <$> inferType (UncurryS [(Hidden, x) | (Visible, x) <- ps] ct) | 1349 | cty <- removeHiddenUnit <$> inferType (UncurryS [(Hidden, x) | (Visible, x) <- ps] ct) |
1349 | tellType (sourceInfo cn) cty | 1350 | -- tellType (sourceInfo cn) cty |
1350 | let pars = zipWith (\x -> second $ STyped . flip (,) TType . rUp (1+j) x) [0..] $ drop (length ps) $ fst $ getParams cty | 1351 | let pars = zipWith (\x -> second $ STyped . flip (,) TType . rUp (1+j) x) [0..] $ drop (length ps) $ fst $ getParams cty |
1351 | act = length . fst . getParams $ cty | 1352 | act = length . fst . getParams $ cty |
1352 | acts = map fst . fst . getParams $ cty | 1353 | acts = map fst . fst . getParams $ cty |
@@ -1451,7 +1452,7 @@ joinEnv e1 e2 = do | |||
1451 | 1452 | ||
1452 | downTo n m = map Var [n+m-1, n+m-2..n] | 1453 | downTo n m = map Var [n+m-1, n+m-2..n] |
1453 | 1454 | ||
1454 | tellType si t = tell $ mkInfoItem (sourceInfo si) $ plainShow $ DTypeNamespace True $ mkDoc False (t, TType) | 1455 | tellType si t = tell $ mkInfoItem (sourceInfo si) $ DTypeNamespace True $ mkDoc False (t, TType) |
1455 | 1456 | ||
1456 | 1457 | ||
1457 | -------------------------------------------------------------------------------- pretty print | 1458 | -------------------------------------------------------------------------------- pretty print |