module Database.Bolt.Value.Type where
import Control.Monad.Trans.State (StateT (..), evalStateT)
import Data.ByteString (ByteString)
import Data.Map.Strict (Map)
import Data.Text (Text)
import Data.Word (Word8)
type UnpackT = StateT ByteString
data Structure = Structure { signature :: Word8
, fields :: [Value]
}
deriving (Show, Eq)
class FromStructure a where
fromStructure :: Monad m => Structure -> m a
class ToStructure a where
toStructure :: a -> Structure
class BoltValue a where
pack :: a -> ByteString
unpackT :: Monad m => UnpackT m a
unpack :: Monad m => ByteString -> m a
unpack = evalStateT unpackT
data Value = N ()
| B Bool
| I Int
| F Double
| T Text
| L [Value]
| M (Map Text Value)
| S Structure
deriving (Show, Eq)
data Node = Node { nodeIdentity :: Int
, labels :: [Text]
, nodeProps :: Map Text Value
}
deriving (Show, Eq)
data Relationship = Relationship { relIdentity :: Int
, startNodeId :: Int
, endNodeId :: Int
, relType :: Text
, relProps :: Map Text Value
}
deriving (Show, Eq)
data URelationship = URelationship { urelIdentity :: Int
, urelType :: Text
, urelProps :: Map Text Value
}
deriving (Show, Eq)
data Path = Path { pathNodes :: [Node]
, pathRelationships :: [URelationship]
, pathSequence :: [Int]
}
deriving (Show, Eq)