]> Git — Sourcephile - haskell/symantic.git/blob - Language/LOL/Symantic/AST.hs
init
[haskell/symantic.git] / Language / LOL / Symantic / AST.hs
1 {-# LANGUAGE Rank2Types #-}
2 module Language.LOL.Symantic.AST where
3
4 import Data.Text (Text)
5 import qualified Data.Text as Text
6
7 -- * Type 'AST'
8
9 -- | Abstract Syntax Tree.
10 data AST
11 = AST Text [AST]
12 deriving (Eq, Show)
13
14 -- * Type 'Error_Read'
15
16 data Error_Read
17 = Error_Read Text
18 deriving (Eq, Show)
19
20 read_safe :: Read a => Text -> Either Error_Read a
21 read_safe t =
22 case reads $ Text.unpack t of
23 [(x, "")] -> Right x
24 _ -> Left $ Error_Read t