| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Domain.Converter.Type
Description
This module defines types and functions for converting Bolt (Neo4j) elements and interactants into Haskell types.
Base
exact- Converts anElem(such as nodes or relationships) into anInteractant(and can be extend withExplainor other interactant types). It handles errors by throwing aParsingErrorif the conversion fails.
exactRaw- Converts anInteractant(or any type, i.o.Explain) into a specificElem. It handles errors by throwing aParsingErrorif the conversion fails.
Additional
- Data types for representing Neo4j elements and identities, where the
Identitytype is introduced to facilitate the mapping of Neo4j objects and building relationships.
- Type classes for converting from database values and extracting interactants.
Synopsis
- data Elem
- data Identity
- newtype ParsingError = ParsingError Text
- class FromValue a where
- fromValue :: Value -> Either ParsingError a
- maybeFromValue :: Maybe Value -> Maybe a
- class ElemInteractant a where
- exactInteractant :: Elem -> Either ParsingError a
- class InteractantElem a where
- exactElem :: Interactant -> Either ParsingError a
- exact :: ElemInteractant a => Elem -> IO a
- exactRaw :: InteractantElem a => Interactant -> IO a
Documentation
The Elem data type represents various types of Bolt (Neo4j) elements that
can be extracted from the database. It includes:
Constructors:
Constructors
| SNode Node | |
| SRel Relationship | |
| SURel URelationship | |
| SPath Path |
The Identity data type represents various IDs that can be associated with
nodes or relationships in the graph:
Constructors:
NodeId- Represents a node's unique identifier.URelId- Represents a universal (undirected) relationship's unique identifier.RelStartNodeId- Represents the starting node ID of a relationship.RelTargetNodeId- Represents the target node ID of a relationship.
Constructors
| NodeId Int | |
| URelId Int | |
| RelStartNodeId Int | |
| RelTargetNodeId Int |
Instances
newtype ParsingError #
Constructors
| ParsingError Text |
Instances
| Exception ParsingError # | |
Defined in Domain.Converter.Type Methods toException :: ParsingError -> SomeException # fromException :: SomeException -> Maybe ParsingError # displayException :: ParsingError -> String # | |
| Show ParsingError # | |
Defined in Domain.Converter.Type Methods showsPrec :: Int -> ParsingError -> ShowS # show :: ParsingError -> String # showList :: [ParsingError] -> ShowS # | |
The FromValue type class is used to convert a Value (from the Bolt database)
into a specific Haskell type a.
Methods
fromValue :: Value -> Either ParsingError a #
Attempts to convert a Value to a specific Haskell type a.
This function takes a Value from the Bolt database and attempts to convert
it to the desired type. If the conversion fails, it returns a ParsingError.
Otherwise, it returns the converted value.
maybeFromValue :: Maybe Value -> Maybe a #
Attempts to convert a `Maybe Value` to a specific Haskell type a.
This function takes an optional Value and attempts
to convert it to the desired type.
Instances
| FromValue String # | |
Defined in Domain.Converter.Instances | |
| FromValue Float # | Converts a Bolt |
Defined in Domain.Converter.Instances | |
| FromValue Int # | |
Defined in Domain.Converter.Instances | |
| FromValue a => FromValue (Maybe a) # | Converts a Bolt |
Defined in Domain.Converter.Instances | |
| FromValue a => FromValue [a] # | Converts a Bolt |
Defined in Domain.Converter.Instances | |
class ElemInteractant a where #
The ElemInteractant type class defines how to extract an interactant from a Subject.
It allows us to convert various database entities into interactants.
Usage:
This type class is used to read from the database.
Methods
exactInteractant :: Elem -> Either ParsingError a #
Instances
class InteractantElem a where #
The InteractantElem type class defines how to extract an element from an Interactant.
This allows specific parts of an Interactant to be converted into Masks.
Usage:
This function is used to write into the database.
Methods
exactElem :: Interactant -> Either ParsingError a #
Converts an Interactant to a specific type a.
This function takes an Interactant and attempts to extract a specific
element of type a from it.
Instances
| InteractantElem NodeMask # | Converts a node interactant to a |
Defined in Domain.Converter.Instances Methods | |
| InteractantElem RelMask # | Converts a relation of |
Defined in Domain.Converter.Instances Methods | |
exact :: ElemInteractant a => Elem -> IO a #
exact converts a Subject to an interactant by using the exactInteractant function.
It throws a ParsingError if the conversion fails; otherwise, it returns the result.
Usage:
This function is used to read from the database.
exactRaw :: InteractantElem a => Interactant -> IO a #
exactRaw converts an Interactant to a specific element using exactElem.
Similar to exact, it throws a ParsingError if the conversion fails.
Usage:
This function is used to write into the database.