graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.Incremental.Internal.Rule

Description

Defines the basic Rule datatype and its core operations.

Synopsis

Documentation

newtype Rule m a b Source #

A value of type Rule m a b is a build rule: a computation that describes how to build a value of type b from a value of type a in a monad m. What distinguishes Rule m a b from an ordinary function of type a -> m b is that it can be made incremental (in the sense of “incremental compilation”)—after executing it, future executions can perform a subset of the required work if only a portion of the input changed.

To achieve this, Rules have a more restrictive interface: there is no Monad (Rule m a) instance, for example. Instead, Rules are composed using the Arrow hierarchy of operations, which ensures that the dependency graph of build rules is mostly static (though it may contain conditional branches, and combinators such as keyed can express restricted forms of dynamic dependencies). Each atomic rule may be defined using the Monad instance for m, but incrementalization is not supported inside those rules — they are treated as a single, monolithic computation.

Atomic rules are created with the arrM function, and caching can be added to a rule using the cache combinator. Rules can be executed using the build function, which returns a Result. A Result contains the built value, accessible via result, but it also allows supplying a new input value using rebuild to produce a new result incrementally.

Constructors

Rule (forall r. Accesses -> a -> (Accesses -> b -> Rule m a b -> m r) -> m r) 

Instances

Instances details
Monad m => ArrowKleisli m (Rule m) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

arrM :: (a -> m b) -> Rule m a b Source #

MonadUnique m => ArrowCache m (Rule m) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Cache

Methods

cache :: Cacheable a => Rule m a b -> Rule m a b Source #

newDependency :: Rule m a (Dependency a) Source #

dependOn :: Cacheable a => Rule m (Dependency a) a Source #

bindDepend :: Rule m (DependT m a) a Source #

Arrow (Rule m) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

arr :: (b -> c) -> Rule m b c #

first :: Rule m b c -> Rule m (b, d) (c, d) #

second :: Rule m b c -> Rule m (d, b) (d, c) #

(***) :: Rule m b c -> Rule m b' c' -> Rule m (b, b') (c, c') #

(&&&) :: Rule m b c -> Rule m b c' -> Rule m b (c, c') #

ArrowChoice (Rule m) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

left :: Rule m b c -> Rule m (Either b d) (Either c d) #

right :: Rule m b c -> Rule m (Either d b) (Either d c) #

(+++) :: Rule m b c -> Rule m b' c' -> Rule m (Either b b') (Either c c') #

(|||) :: Rule m b d -> Rule m c d -> Rule m (Either b c) d #

Profunctor (Rule m) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

dimap :: (a -> b) -> (c -> d) -> Rule m b c -> Rule m a d

lmap :: (a -> b) -> Rule m b c -> Rule m a c

rmap :: (b -> c) -> Rule m a b -> Rule m a c

(#.) :: forall a b c q. Coercible c b => q b c -> Rule m a b -> Rule m a c

(.#) :: forall a b c q. Coercible b a => Rule m b c -> q a b -> Rule m a c

Choice (Rule m) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

left' :: Rule m a b -> Rule m (Either a c) (Either b c)

right' :: Rule m a b -> Rule m (Either c a) (Either c b)

Strong (Rule m) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

first' :: Rule m a b -> Rule m (a, c) (b, c)

second' :: Rule m a b -> Rule m (c, a) (c, b)

ArrowDistribute (Rule m) Source #

Unlike traverseA, using keyed preserves incrementalization: if the input rule is incremental in its argument, the resulting rule will be incremental as well for any entries in the map that do not change between builds.

Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

keyed :: (Eq k, Hashable k) => Rule m (e, (k, (a, s))) b -> Rule m (e, (HashMap k a, s)) (HashMap k b) Source #

Category (Rule m :: Type -> Type -> Type) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

id :: forall (a :: k). Rule m a a #

(.) :: forall (b :: k) (c :: k) (a :: k). Rule m b c -> Rule m a b -> Rule m a c #

Functor (Rule m a) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

fmap :: (a0 -> b) -> Rule m a a0 -> Rule m a b #

(<$) :: a0 -> Rule m a b -> Rule m a a0 #

Applicative (Rule m a) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

pure :: a0 -> Rule m a a0 #

(<*>) :: Rule m a (a0 -> b) -> Rule m a a0 -> Rule m a b #

liftA2 :: (a0 -> b -> c) -> Rule m a a0 -> Rule m a b -> Rule m a c #

(*>) :: Rule m a a0 -> Rule m a b -> Rule m a b #

(<*) :: Rule m a a0 -> Rule m a b -> Rule m a a0 #

build :: Applicative m => Rule m a b -> a -> m (Result m a b) Source #

data Result m a b Source #

Constructors

Result 

Fields

Instances

Instances details
Functor (Result m a) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

fmap :: (a0 -> b) -> Result m a a0 -> Result m a b #

(<$) :: a0 -> Result m a b -> Result m a a0 #

rebuild :: Applicative m => Result m a b -> a -> m (Result m a b) Source #

rComp :: Rule m a1 b -> Rule m a2 a1 -> Rule m a2 b Source #

rId :: Rule m a a Source #

rArr :: (a -> b) -> Rule m a b Source #

rArrM :: Monad m => (a -> m b) -> Rule m a b Source #

rFirst :: Rule m a b1 -> Rule m (a, b2) (b1, b2) Source #

rLeft :: Rule m a b1 -> Rule m (Either a b2) (Either b1 b2) Source #

rPure :: b -> Rule m a b Source #

rSecond :: Rule m a1 b -> Rule m (a2, a1) (a2, b) Source #

rRight :: Rule m a1 b -> Rule m (Either a2 a1) (Either a2 b) Source #

rSplit :: Rule m a1 b1 -> Rule m a2 b2 -> Rule m (a1, a2) (b1, b2) Source #

rFanout :: Rule m a b1 -> Rule m a b2 -> Rule m a (b1, b2) Source #

rFork :: Rule m a1 b1 -> Rule m a2 b2 -> Rule m (Either a1 a2) (Either b1 b2) Source #

rFanin :: Rule m a1 b -> Rule m a2 b -> Rule m (Either a1 a2) b Source #

class Arrow arr => ArrowDistribute arr where Source #

Methods

keyed :: (Eq k, Hashable k) => arr (e, (k, (a, s))) b -> arr (e, (HashMap k a, s)) (HashMap k b) Source #

Distributes an arrow that operates on key-value pairs, over a HashMap in an order-independent way.

This is intended to be used as a control operator in proc notation; see Note [Weird control operator types] in Control.Arrow.Extended.

Instances

Instances details
ArrowDistribute (Rule m) Source #

Unlike traverseA, using keyed preserves incrementalization: if the input rule is incremental in its argument, the resulting rule will be incremental as well for any entries in the map that do not change between builds.

Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

keyed :: (Eq k, Hashable k) => Rule m (e, (k, (a, s))) b -> Rule m (e, (HashMap k a, s)) (HashMap k b) Source #

(Monoid w, ArrowDistribute arr) => ArrowDistribute (WriterA w arr) Source # 
Instance details

Defined in Hasura.Incremental.Internal.Rule

Methods

keyed :: (Eq k, Hashable k) => WriterA w arr (e, (k, (a, s))) b -> WriterA w arr (e, (HashMap k a, s)) (HashMap k b) Source #