Skip to content

Commit

Permalink
Add basic printer
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdone committed Jan 14, 2025
1 parent d4d2768 commit 8bc02d4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Hell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,25 @@ instance Pretty IMetaVar where
"t"
<> ByteString.byteString (Text.encodeUtf8 $ Text.pack $ show i)

instance Pretty (UTerm t) where
pretty = \case
UVar _ _ v -> pretty v
UApp _ _ f x -> "(" <> pretty f <> " " <> pretty x <> ")"
UForall prim _ _ _ _ _ _ _ -> pretty prim
ULam _ _ binding _ t ->
"(\\" <> pretty binding <> " -> " <> pretty t <> ")"

instance Pretty Prim where
pretty = \case
LitP p -> pretty $ HSE.prettyPrint p
NameP s -> pretty s
UnitP -> "()"

instance Pretty Binding where
pretty = \case
Singleton v -> pretty v
Tuple xs -> "(" <> mconcat (List.intersperse ", " (map pretty xs)) <> ")"

instance (Pretty a) => Pretty (IRep a) where
pretty = \case
IVar a -> pretty a
Expand Down

0 comments on commit 8bc02d4

Please sign in to comment.