@@ -20,16 +20,16 @@ import qualified Data.Text.Prettyprint.Doc as Pretty
2020import qualified Data.Text.Prettyprint.Doc.Render.String as Pretty
2121import qualified Data.Text.Prettyprint.Doc.Render.Terminal as Pretty
2222
23- showCore :: Term Core Name -> String
23+ showCore :: Term Core User -> String
2424showCore = Pretty. renderString . Pretty. layoutSmart Pretty. defaultLayoutOptions . Pretty. unAnnotate . prettyCore Ascii
2525
26- printCore :: Term Core Name -> IO ()
26+ printCore :: Term Core User -> IO ()
2727printCore p = Pretty. putDoc (prettyCore Unicode p) *> putStrLn " "
2828
29- showFile :: File (Term Core Name ) -> String
29+ showFile :: File (Term Core User ) -> String
3030showFile = showCore . fileBody
3131
32- printFile :: File (Term Core Name ) -> IO ()
32+ printFile :: File (Term Core User ) -> IO ()
3333printFile = printCore . fileBody
3434
3535type AnsiDoc = Pretty. Doc Pretty. AnsiStyle
@@ -44,10 +44,8 @@ type Prec = Int
4444
4545data Style = Unicode | Ascii
4646
47- name :: Name -> AnsiDoc
48- name = \ case
49- Gen p -> pretty p
50- User n -> encloseIf (needsQuotation n) (symbol " #{" ) (symbol " }" ) (pretty n)
47+ name :: User -> AnsiDoc
48+ name n = encloseIf (needsQuotation n) (symbol " #{" ) (symbol " }" ) (pretty n)
5149
5250with :: (Member (Reader Prec ) sig , Carrier sig m ) => Prec -> m a -> m a
5351with n = local (const n)
@@ -63,7 +61,7 @@ prettify :: (Member (Reader [AnsiDoc]) sig, Member (Reader Prec) sig, Carrier si
6361 -> Core (Const (m AnsiDoc )) a
6462 -> m AnsiDoc
6563prettify style = \ case
66- Let a -> pure $ keyword " let" <+> name ( User a)
64+ Let a -> pure $ keyword " let" <+> name a
6765 Const a :>> Const b -> do
6866 prec <- ask @ Prec
6967 fore <- with 12 a
@@ -108,7 +106,7 @@ prettify style = \case
108106
109107 -- Annotations are not pretty-printed, as it lowers the signal/noise ratio too profoundly.
110108 Ann _ (Const c) -> c
111- where bind (Ignored x) f = let x' = name ( User x) in (,) x' <$> local (x': ) (getConst (unScope f))
109+ where bind (Ignored x) f = let x' = name x in (,) x' <$> local (x': ) (getConst (unScope f))
112110 lambda = case style of
113111 Unicode -> symbol " λ"
114112 Ascii -> symbol " \\ "
@@ -120,7 +118,7 @@ prettify style = \case
120118appending :: Functor f => AnsiDoc -> f AnsiDoc -> f AnsiDoc
121119appending k item = (keyword k <+> ) <$> item
122120
123- prettyCore :: Style -> Term Core Name -> AnsiDoc
121+ prettyCore :: Style -> Term Core User -> AnsiDoc
124122prettyCore s = run . runReader @ Prec 0 . runReader @ [AnsiDoc ] [] . cata id (prettify s) bound (pure . name)
125123 where bound (Z _) = asks (head @ AnsiDoc )
126124 bound (S n) = local (tail @ AnsiDoc ) n
0 commit comments