@@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
module Gyehoek.Sexp.Syntax
|
||||
( DatumF(..)
|
||||
, Simple(..)
|
||||
@@ -6,12 +7,22 @@ module Gyehoek.Sexp.Syntax
|
||||
, Prefix(..)
|
||||
, Delimiter(..)
|
||||
, Label(..)
|
||||
, SourcePos(..)
|
||||
, Datum
|
||||
, Cofree((:<))
|
||||
, Fix(..)
|
||||
) where
|
||||
|
||||
import Language.Haskell.TH.Syntax (Lift)
|
||||
import Data.Scientific (Scientific)
|
||||
import Data.ByteString (ByteString)
|
||||
import Gyehoek.Prelude hiding (Simple)
|
||||
import Gyehoek.Prelude hiding ((:<), Simple)
|
||||
import Text.Megaparsec.Pos (SourcePos(..))
|
||||
import Control.Comonad.Cofree (Cofree((:<)))
|
||||
import Data.Fix (Fix (..))
|
||||
import Data.Functor.Foldable
|
||||
import Text.Show.Deriving (deriveShow1)
|
||||
import qualified Control.Comonad.Trans.Cofree as F
|
||||
|
||||
|
||||
data DatumF a
|
||||
@@ -19,16 +30,16 @@ data DatumF a
|
||||
| CompoundF (CompoundF a)
|
||||
| LabeledF Label a
|
||||
| LabelRefF Label
|
||||
deriving stock (Show, Eq, Data, Generic, Lift)
|
||||
deriving stock (Show, Eq, Data, Generic, Lift, Functor, Foldable, Traversable)
|
||||
deriving anyclass (NFData)
|
||||
|
||||
data Simple
|
||||
= SimpleBool Bool
|
||||
| SimpleNumber Scientific
|
||||
| SimpleChar Char
|
||||
| SimpleString Text
|
||||
| SimpleSymbol Text
|
||||
| SimpleBytevector ByteString
|
||||
= Boolean Bool
|
||||
| Number Scientific
|
||||
| Character Char
|
||||
| String Text
|
||||
| Symbol Text
|
||||
| Bytevector ByteString
|
||||
deriving stock (Show, Eq, Data, Generic, Lift)
|
||||
deriving anyclass (NFData)
|
||||
|
||||
@@ -37,7 +48,7 @@ data CompoundF a
|
||||
| DotListF (NonEmpty a) a
|
||||
| VectorF (List a)
|
||||
| AbbrevF Prefix a
|
||||
deriving stock (Show, Eq, Data, Generic, Lift)
|
||||
deriving stock (Show, Eq, Data, Generic, Lift, Functor, Foldable, Traversable)
|
||||
deriving anyclass (NFData)
|
||||
|
||||
data Prefix
|
||||
@@ -56,3 +67,10 @@ newtype Label = MkLabel Natural
|
||||
deriving stock (Data, Generic, Lift)
|
||||
deriving newtype (Eq, Ord, Show)
|
||||
deriving anyclass (NFData)
|
||||
|
||||
deriveShow1 ''CompoundF
|
||||
deriveShow1 ''DatumF
|
||||
|
||||
|
||||
|
||||
type Datum = Fix DatumF
|
||||
|
||||
Reference in New Issue
Block a user