{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveLift #-}
{-# LANGUAGE NamedFieldPuns #-}
module Data.Morpheus.Types.Internal.AST.Base
( Key
, Collection
, Ref(..)
, Position(..)
, Message
, anonymousRef
, Name
, Description
)
where
import Data.Aeson ( FromJSON
, ToJSON
)
import Data.Text ( Text )
import GHC.Generics ( Generic )
import Language.Haskell.TH.Syntax ( Lift )
import Instances.TH.Lift ( )
type Key = Text
type Message = Text
type Name = Key
type Description = Key
type Collection a = [(Key, a)]
data Position = Position
{ line :: Int
, column :: Int
} deriving (Show, Generic, FromJSON, ToJSON, Lift)
data Ref = Ref
{ refName :: Key
, refPosition :: Position
} deriving (Show,Lift)
instance Eq Ref where
(Ref id1 _) == (Ref id2 _) = id1 == id2
instance Ord Ref where
compare (Ref x _) (Ref y _) = compare x y
anonymousRef :: Key -> Ref
anonymousRef refName = Ref { refName, refPosition = Position 0 0 }