1 {-# LANGUAGE OverloadedStrings #-}
2 -- | Abstract Syntax Tree.
3 module Language.LOL.Symantic.AST where
5 import qualified Data.List as List
6 import Data.Text (Text)
7 import qualified Data.Text as Text
13 -- | Custom 'Show' instance a little bit more readable
14 -- than the automatically derived one.
15 instance Show AST where
16 showsPrec p ast@(AST f args) =
17 let n = Text.unpack f in
19 AST _ [] -> showString n
22 showString ("("++n++") ") .
27 showString (" "++n++" ") .
32 showString (List.intercalate ", " $ show <$> args) .
35 -- * Type 'Error_Read'
40 read_safe :: Read a => Text -> Either Error_Read a
42 case reads $ Text.unpack t of
44 _ -> Left $ Error_Read t