summaryrefslogtreecommitdiff
path: root/src/LambdaCube/Compiler/DesugaredSource.hs
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-05-05 17:55:01 +0200
committerPéter Diviánszky <divipp@gmail.com>2016-05-05 17:55:01 +0200
commit9e232c77ee6d0948f7dd5727d3ec568bbedf4316 (patch)
treed9f64543cf48a964fd29e95b87b824f9b5c2a877 /src/LambdaCube/Compiler/DesugaredSource.hs
parentf24ab8bd8d5cb60a7a75e52655b567f916f73a53 (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.hs19
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
469shLam usedVar h a b = shLam_ usedVar h (Just a) b 468shLam usedVar h a b = shLam_ usedVar h (Just a) b
470 469
471shLam_ False (BPi Hidden) (Just (DText "'CW" `DApp` a)) b = DFreshName False $ showContext (DUp 0 a) b 470simpleFo (DExpand x _) = x
471simpleFo x = x
472
473shLam_ 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
509showLam x (DFreshName u d) = DFreshName u $ showLam (DUp 0 x) d 507showLam x (DFreshName u d) = DFreshName u $ showLam (DUp 0 x) d
510showLam x (DLam xs y) = DLam (DSep (InfixR 11) x xs) y 508showLam x (DLam xs y) = DLam (DSep (InfixR 11) x xs) y
511showLam x y = DLam x y 509showLam x y = DLam x y
512 510
513shLet i a b = DLet' (DLet "=" (blue $ shVar i) $ DUp i a) (DUp i b) 511shLet i a b = DLet' (DLet "=" (blue $ shVar i) $ DUp i a) (DUp i b)
514shLet_ a b = DFreshName True $ DLet' (DLet "=" (shVar 0) $ DUp 0 a) b 512
513showLet x (DFreshName u d) = DFreshName u $ showLet (DUp 0 x) d
514showLet x (DLet' xs y) = DLet' (DSemi x xs) y
515showLet x y = DLet' x y
516
517shLet_ a b = DFreshName True $ showLet (DLet "=" (shVar 0) $ DUp 0 a) b
515 518
516-------------------------------------------------------------------------------- statement 519-------------------------------------------------------------------------------- statement
517 520