Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- node :: forall a m. (MonadGraphula m, Logging m a, Arbitrary a, HasDependencies a, GenerateKey a, PersistEntityBackend a ~ SqlBackend, PersistEntity a, Typeable a, GraphulaSafeToInsert a) => Dependencies a -> NodeOptions a -> m (Entity a)
- nodeKeyed :: forall a m. (MonadGraphula m, Logging m a, Arbitrary a, HasDependencies a, PersistEntityBackend a ~ SqlBackend, PersistEntity a, Typeable a, GraphulaSafeToInsert a) => Key a -> Dependencies a -> NodeOptions a -> m (Entity a)
- data NodeOptions a
- edit :: (a -> a) -> NodeOptions a
- ensure :: (a -> Bool) -> NodeOptions a
- data GenerationFailure
Generating
node :: forall a m. (MonadGraphula m, Logging m a, Arbitrary a, HasDependencies a, GenerateKey a, PersistEntityBackend a ~ SqlBackend, PersistEntity a, Typeable a, GraphulaSafeToInsert a) => Dependencies a -> NodeOptions a -> m (Entity a) Source #
Generate a node with a default (Database-provided) key
a <- node @A () mempty
nodeKeyed :: forall a m. (MonadGraphula m, Logging m a, Arbitrary a, HasDependencies a, PersistEntityBackend a ~ SqlBackend, PersistEntity a, Typeable a, GraphulaSafeToInsert a) => Key a -> Dependencies a -> NodeOptions a -> m (Entity a) Source #
Generate a node with an explictly-given key
let someKey = UUID.fromString "..." a <- nodeKeyed @A someKey () mempty
NodeOptions
data NodeOptions a Source #
Options for generating an individual node
NodeOptions
can be created and combined with the Monoidal operations (<>)
and mempty
.
a1 <- node @A () mempty a2 <- node @A () $ edit $ \a -> a { someField = True } a3 <- node @A () $ ensure $ (== True) . someField
Instances
Generic (NodeOptions a) Source # | |
Defined in Graphula.Node type Rep (NodeOptions a) :: Type -> Type # from :: NodeOptions a -> Rep (NodeOptions a) x # to :: Rep (NodeOptions a) x -> NodeOptions a # | |
Semigroup (NodeOptions a) Source # | |
Defined in Graphula.Node (<>) :: NodeOptions a -> NodeOptions a -> NodeOptions a # sconcat :: NonEmpty (NodeOptions a) -> NodeOptions a # stimes :: Integral b => b -> NodeOptions a -> NodeOptions a # | |
Monoid (NodeOptions a) Source # | |
Defined in Graphula.Node mempty :: NodeOptions a # mappend :: NodeOptions a -> NodeOptions a -> NodeOptions a # mconcat :: [NodeOptions a] -> NodeOptions a # | |
type Rep (NodeOptions a) Source # | |
Defined in Graphula.Node |
edit :: (a -> a) -> NodeOptions a Source #
Modify the node after it's been generated
a <- node @A () $ edit $ \a -> a { someField = True }
ensure :: (a -> Bool) -> NodeOptions a Source #
Require a node to satisfy the specified predicate
a <- node @A () $ ensure $ (== True) . someField
N.B. ensuring a condition that is infrequently met can be innefficient.
Exceptions
data GenerationFailure Source #
GenerationFailureMaxAttemptsToConstrain TypeRep | Could not satisfy constraints defined using |
GenerationFailureMaxAttemptsToInsert TypeRep | Could not satisfy database constraints on |
Instances
Eq GenerationFailure Source # | |
Defined in Graphula.Node (==) :: GenerationFailure -> GenerationFailure -> Bool # (/=) :: GenerationFailure -> GenerationFailure -> Bool # | |
Show GenerationFailure Source # | |
Defined in Graphula.Node showsPrec :: Int -> GenerationFailure -> ShowS # show :: GenerationFailure -> String # showList :: [GenerationFailure] -> ShowS # | |
Exception GenerationFailure Source # | |
Defined in Graphula.Node |