elm/compiler/SourceSyntax/Literal.hs

20 lines
522 B
Haskell
Raw Normal View History

module SourceSyntax.Literal where
import SourceSyntax.PrettyPrint
import qualified Text.PrettyPrint as PP
data Literal = IntNum Int
| FloatNum Double
| Chr Char
| Str String
| Boolean Bool
deriving (Eq, Ord, Show)
instance Pretty Literal where
pretty literal =
case literal of
IntNum n -> PP.int n
FloatNum n -> PP.double n
2013-07-12 23:05:48 +00:00
Chr c -> PP.quotes (PP.char c)
Str s -> PP.text (show s)
Boolean bool -> PP.text (show bool)