1 implementation module ast
8 instance toString AST where toString a = display $ renderCompact $ pretty a
9 instance toString Function where toString a = display $ renderCompact $ pretty a
10 instance toString Expression where toString a = display $ renderCompact $ pretty a
11 instance toString Value where toString a = display $ renderCompact $ pretty a
13 instance Pretty Expression
15 pretty (Literal v) = pretty v
16 pretty (Variable v) = string v
17 pretty (Apply a b) = parens (pretty a <+> pretty b)
18 pretty (Lambda a b) = string "\\" <-> string a <+> string "->" <+> pretty b
19 pretty (Let v a b) = string "let" <+> string v <+> string "=" <+> pretty a <+> string "in" <+> pretty b
20 pretty (Code b) = string "code" <+> string b
22 instance Pretty Function
24 pretty (Function n args a) = string n <+> fold (<+>) (map string args) <+> string "=" <+> pretty a
28 pretty (AST a) = pretty a
32 pretty (Int i) = int i
33 pretty (Bool b) = bool b
34 pretty (Char c) = char c