diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-05-05 17:55:01 +0200 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-05-05 17:55:01 +0200 |
commit | 9e232c77ee6d0948f7dd5727d3ec568bbedf4316 (patch) | |
tree | d9f64543cf48a964fd29e95b87b824f9b5c2a877 /src/LambdaCube/Compiler/DesugaredSource.hs | |
parent | f24ab8bd8d5cb60a7a75e52655b567f916f73a53 (diff) |
improve pretty printing & try to fix local function handling
Diffstat (limited to 'src/LambdaCube/Compiler/DesugaredSource.hs')
-rw-r--r-- | src/LambdaCube/Compiler/DesugaredSource.hs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/LambdaCube/Compiler/DesugaredSource.hs b/src/LambdaCube/Compiler/DesugaredSource.hs index 271c678e..074e0299 100644 --- a/src/LambdaCube/Compiler/DesugaredSource.hs +++ b/src/LambdaCube/Compiler/DesugaredSource.hs | |||
@@ -235,7 +235,6 @@ instance PShow FName where | |||
235 | pShow (CFName _ (SData s)) = pShow s | 235 | pShow (CFName _ (SData s)) = pShow s |
236 | pShow s = maybe (error "show") text' $ lookup s $ map (\(a, b) -> (b, a)) fntable | 236 | pShow s = maybe (error "show") text' $ lookup s $ map (\(a, b) -> (b, a)) fntable |
237 | where | 237 | where |
238 | text' "Nil" = "[]" | ||
239 | text' ":" = pShow ConsName | 238 | text' ":" = pShow ConsName |
240 | text' s = text s | 239 | text' s = text s |
241 | 240 | ||
@@ -468,7 +467,10 @@ shApp Hidden a b = DApp a (DAt b) | |||
468 | 467 | ||
469 | shLam usedVar h a b = shLam_ usedVar h (Just a) b | 468 | shLam usedVar h a b = shLam_ usedVar h (Just a) b |
470 | 469 | ||
471 | shLam_ False (BPi Hidden) (Just (DText "'CW" `DApp` a)) b = DFreshName False $ showContext (DUp 0 a) b | 470 | simpleFo (DExpand x _) = x |
471 | simpleFo x = x | ||
472 | |||
473 | shLam_ False (BPi Hidden) (Just ((simpleFo -> DText "'CW") `DApp` a)) b = DFreshName False $ showContext (DUp 0 a) b | ||
472 | where | 474 | where |
473 | showContext x (DFreshName u d) = DFreshName u $ showContext (DUp 0 x) d | 475 | showContext x (DFreshName u d) = DFreshName u $ showContext (DUp 0 x) d |
474 | showContext x (DParContext xs y) = DParContext (DComma x xs) y | 476 | showContext x (DParContext xs y) = DParContext (DComma x xs) y |
@@ -500,18 +502,19 @@ shLam_ usedVar h a b = DFreshName usedVar $ lam (p $ DUp 0 <$> a) b | |||
500 | showForall s x (DForall s' xs y) | s == s' = DForall s (DSep (InfixR 11) x xs) y | 502 | showForall s x (DForall s' xs y) | s == s' = DForall s (DSep (InfixR 11) x xs) y |
501 | showForall s x y = DForall s x y | 503 | showForall s x y = DForall s x y |
502 | 504 | ||
503 | -- TODO: use other sign instead of (=>) | 505 | showContext x y = DContext' x y |
504 | showContext x (DFreshName u d) = DFreshName u $ showContext (DUp 0 x) d | ||
505 | showContext x (DParContext xs y) = DParContext (DComma x xs) y | ||
506 | showContext x (DContext xs y) = DParContext (DComma x xs) y | ||
507 | showContext x y = DContext x y | ||
508 | 506 | ||
509 | showLam x (DFreshName u d) = DFreshName u $ showLam (DUp 0 x) d | 507 | showLam x (DFreshName u d) = DFreshName u $ showLam (DUp 0 x) d |
510 | showLam x (DLam xs y) = DLam (DSep (InfixR 11) x xs) y | 508 | showLam x (DLam xs y) = DLam (DSep (InfixR 11) x xs) y |
511 | showLam x y = DLam x y | 509 | showLam x y = DLam x y |
512 | 510 | ||
513 | shLet i a b = DLet' (DLet "=" (blue $ shVar i) $ DUp i a) (DUp i b) | 511 | shLet i a b = DLet' (DLet "=" (blue $ shVar i) $ DUp i a) (DUp i b) |
514 | shLet_ a b = DFreshName True $ DLet' (DLet "=" (shVar 0) $ DUp 0 a) b | 512 | |
513 | showLet x (DFreshName u d) = DFreshName u $ showLet (DUp 0 x) d | ||
514 | showLet x (DLet' xs y) = DLet' (DSemi x xs) y | ||
515 | showLet x y = DLet' x y | ||
516 | |||
517 | shLet_ a b = DFreshName True $ showLet (DLet "=" (shVar 0) $ DUp 0 a) b | ||
515 | 518 | ||
516 | -------------------------------------------------------------------------------- statement | 519 | -------------------------------------------------------------------------------- statement |
517 | 520 | ||