{-|
Module      : Text.SExpression.Types
Description : Types
Copyright   : (C) Richard Cook, 2019
Licence     : MIT
Maintainer  : rcook@rcook.org
Stability   : stable
Portability : portable

This module provides parser context type 'Parser' and value type 'SExpr'.
-}

{-# OPTIONS_GHC -Wall -Werror #-}

module Text.SExpression.Types
    ( Parser
    , SExpr(..)
    ) where

import Data.Void (Void)
import Text.Megaparsec (Parsec)

-- | Parser context
type Parser = Parsec Void String

-- | S-expression values
data SExpr =
    Atom String                 -- ^ atom
    | List [SExpr]              -- ^ list
    | ConsList [SExpr] SExpr    -- ^ cons list
    | Number Integer            -- ^ number literal
    | String String             -- ^ string literal
    | Bool Bool                 -- ^ Boolean literal
    deriving (SExpr -> SExpr -> Bool
(SExpr -> SExpr -> Bool) -> (SExpr -> SExpr -> Bool) -> Eq SExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SExpr -> SExpr -> Bool
$c/= :: SExpr -> SExpr -> Bool
== :: SExpr -> SExpr -> Bool
$c== :: SExpr -> SExpr -> Bool
Eq, ReadPrec [SExpr]
ReadPrec SExpr
Int -> ReadS SExpr
ReadS [SExpr]
(Int -> ReadS SExpr)
-> ReadS [SExpr]
-> ReadPrec SExpr
-> ReadPrec [SExpr]
-> Read SExpr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SExpr]
$creadListPrec :: ReadPrec [SExpr]
readPrec :: ReadPrec SExpr
$creadPrec :: ReadPrec SExpr
readList :: ReadS [SExpr]
$creadList :: ReadS [SExpr]
readsPrec :: Int -> ReadS SExpr
$creadsPrec :: Int -> ReadS SExpr
Read, Int -> SExpr -> ShowS
[SExpr] -> ShowS
SExpr -> String
(Int -> SExpr -> ShowS)
-> (SExpr -> String) -> ([SExpr] -> ShowS) -> Show SExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SExpr] -> ShowS
$cshowList :: [SExpr] -> ShowS
show :: SExpr -> String
$cshow :: SExpr -> String
showsPrec :: Int -> SExpr -> ShowS
$cshowsPrec :: Int -> SExpr -> ShowS
Show)