on c19ccfe help sign in
22 lines 589 B history raw
1{-# LANGUAGE DeriveDataTypeable #-}
2module SourceSyntax.Literal where
4import Data.Data
5import SourceSyntax.PrettyPrint
6import qualified Text.PrettyPrint as PP
8data Literal = IntNum Int
9 | FloatNum Float
10 | Chr Char
11 | Str String
12 | Boolean Bool
13 deriving (Eq, Ord, Data, Typeable, Show)
15instance Pretty Literal where
16 pretty literal =
17 case literal of
18 IntNum n -> PP.int n
19 FloatNum n -> PP.float n
20 Chr c -> PP.quotes (PP.char c)
21 Str s -> PP.text (show s)
22 Boolean bool -> PP.text (show bool)