diff options
Diffstat (limited to 'src/LambdaCube/Compiler/DesugaredSource.hs')
-rw-r--r-- | src/LambdaCube/Compiler/DesugaredSource.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/LambdaCube/Compiler/DesugaredSource.hs b/src/LambdaCube/Compiler/DesugaredSource.hs index d47726d0..325338bf 100644 --- a/src/LambdaCube/Compiler/DesugaredSource.hs +++ b/src/LambdaCube/Compiler/DesugaredSource.hs | |||
@@ -533,22 +533,22 @@ shLet_ a b = DFreshName True $ showLet (DLet "=" (shVar 0) $ DUp 0 a) b | |||
533 | -------------------------------------------------------------------------------- statement | 533 | -------------------------------------------------------------------------------- statement |
534 | 534 | ||
535 | data Stmt | 535 | data Stmt |
536 | = Let SIName (Maybe SExp) SExp | 536 | = StLet SIName (Maybe SExp) SExp |
537 | | Data SIName [(Visibility, SExp)]{-parameters-} SExp{-type-} [(SIName, SExp)]{-constructor names and types-} | 537 | | Data SIName [(Visibility, SExp)]{-parameters-} SExp{-type-} [(SIName, SExp)]{-constructor names and types-} |
538 | | PrecDef SIName Fixity | 538 | | PrecDef SIName Fixity |
539 | 539 | ||
540 | pattern Primitive n t = Let n (Just t) (SBuiltin "undefined") | 540 | pattern Primitive n t = StLet n (Just t) (SBuiltin "undefined") |
541 | 541 | ||
542 | instance PShow Stmt where | 542 | instance PShow Stmt where |
543 | pShow stmt = vcat . map DResetFreshNames $ case stmt of | 543 | pShow stmt = vcat . map DResetFreshNames $ case stmt of |
544 | Primitive n t -> pure $ shAnn (pShow n) (pShow t) | 544 | Primitive n t -> pure $ shAnn (pShow n) (pShow t) |
545 | Let n ty e -> [shAnn (pShow n) (pShow t) | Just t <- [ty]] ++ [DLet "=" (pShow n) (pShow e)] | 545 | StLet n ty e -> [shAnn (pShow n) (pShow t) | Just t <- [ty]] ++ [DLet "=" (pShow n) (pShow e)] |
546 | Data n ps ty cs -> pure $ nest 2 $ "data" <+> nest 2 (shAnn (foldl DApp (DTypeNamespace True $ pShow n) [shAnn (text "_") (pShow t) | (v, t) <- ps]) (pShow ty)) </> "where" <> nest 2 (hardline <> vcat [shAnn (pShow n) $ pShow $ UncurryS (first (const Hidden) <$> ps) t | (n, t) <- cs]) | 546 | Data n ps ty cs -> pure $ nest 2 $ "data" <+> nest 2 (shAnn (foldl DApp (DTypeNamespace True $ pShow n) [shAnn (text "_") (pShow t) | (v, t) <- ps]) (pShow ty)) </> "where" <> nest 2 (hardline <> vcat [shAnn (pShow n) $ pShow $ UncurryS (first (const Hidden) <$> ps) t | (n, t) <- cs]) |
547 | PrecDef n i -> pure $ pShow i <+> text (sName n) --DOp0 (sName n) i | 547 | PrecDef n i -> pure $ pShow i <+> text (sName n) --DOp0 (sName n) i |
548 | 548 | ||
549 | instance DeBruijnify SIName Stmt where | 549 | instance DeBruijnify SIName Stmt where |
550 | deBruijnify_ k v = \case | 550 | deBruijnify_ k v = \case |
551 | Let sn mt e -> Let sn (deBruijnify_ k v <$> mt) (deBruijnify_ k v e) | 551 | StLet sn mt e -> StLet sn (deBruijnify_ k v <$> mt) (deBruijnify_ k v e) |
552 | x -> error $ "deBruijnify @ " ++ ppShow x | 552 | x -> error $ "deBruijnify @ " ++ ppShow x |
553 | 553 | ||
554 | -------------------------------------------------------------------------------- statement with dependencies | 554 | -------------------------------------------------------------------------------- statement with dependencies |
@@ -570,7 +570,7 @@ sortDefs xs = map snValue <$> scc snId snChildren snRevChildren nodes | |||
570 | where | 570 | where |
571 | need = Set.toList $ case s of | 571 | need = Set.toList $ case s of |
572 | PrecDef{} -> mempty | 572 | PrecDef{} -> mempty |
573 | Let _ mt e -> foldMap names mt <> names e | 573 | StLet _ mt e -> foldMap names mt <> names e |
574 | Data _ ps t cs -> foldMap (names . snd) ps <> names t <> foldMap (names . snd) cs | 574 | Data _ ps t cs -> foldMap (names . snd) ps <> names t <> foldMap (names . snd) cs |
575 | 575 | ||
576 | names = foldName Set.singleton | 576 | names = foldName Set.singleton |
@@ -581,7 +581,7 @@ sortDefs xs = map snValue <$> scc snId snChildren snRevChildren nodes | |||
581 | where | 581 | where |
582 | def = \case | 582 | def = \case |
583 | PrecDef{} -> mempty | 583 | PrecDef{} -> mempty |
584 | Let n _ _ -> [n] | 584 | StLet n _ _ -> [n] |
585 | Data n _ _ cs -> n: map fst cs | 585 | Data n _ _ cs -> n: map fst cs |
586 | 586 | ||
587 | -------------------------------------------------------------------------------- module | 587 | -------------------------------------------------------------------------------- module |