on b00a8cb help sign in
21 lines 546 B history raw
1{-# OPTIONS_GHC -Wall #-}
2module SourceSyntax.Literal where
4import SourceSyntax.PrettyPrint
5import qualified Text.PrettyPrint as PP
7data Literal = IntNum Int
8 | FloatNum Double
9 | Chr Char
10 | Str String
11 | Boolean Bool
12 deriving (Eq, Ord, Show)
14instance Pretty Literal where
15 pretty literal =
16 case literal of
17 IntNum n -> PP.int n
18 FloatNum n -> PP.double n
19 Chr c -> PP.text . show $ c
20 Str s -> PP.text . show $ s
21 Boolean bool -> PP.text (show bool)