| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hasura.Incremental.Internal.Rule
Description
Defines the basic Rule datatype and its core operations.
Synopsis
- newtype Rule m a b = Rule (forall r. Accesses -> a -> (Accesses -> b -> Rule m a b -> m r) -> m r)
- build :: Applicative m => Rule m a b -> a -> m (Result m a b)
- data Result m a b = Result {
- result :: !b
- rebuildRule :: !(Rule m a b)
- rebuild :: Applicative m => Result m a b -> a -> m (Result m a b)
- rComp :: Rule m a1 b -> Rule m a2 a1 -> Rule m a2 b
- rId :: Rule m a a
- rArr :: (a -> b) -> Rule m a b
- rArrM :: Monad m => (a -> m b) -> Rule m a b
- rFirst :: Rule m a b1 -> Rule m (a, b2) (b1, b2)
- rLeft :: Rule m a b1 -> Rule m (Either a b2) (Either b1 b2)
- rPure :: b -> Rule m a b
- rSecond :: Rule m a1 b -> Rule m (a2, a1) (a2, b)
- swapEither :: Either a b -> Either b a
- rRight :: Rule m a1 b -> Rule m (Either a2 a1) (Either a2 b)
- rSplit :: Rule m a1 b1 -> Rule m a2 b2 -> Rule m (a1, a2) (b1, b2)
- rFanout :: Rule m a b1 -> Rule m a b2 -> Rule m a (b1, b2)
- rFork :: Rule m a1 b1 -> Rule m a2 b2 -> Rule m (Either a1 a2) (Either b1 b2)
- fromEither :: Either a a -> a
- rFanin :: Rule m a1 b -> Rule m a2 b -> Rule m (Either a1 a2) b
- class Arrow arr => ArrowDistribute arr where
Documentation
A value of type is a build rule: a computation that describes how to build a
value of type Rule m a bb from a value of type a in a monad m. What distinguishes from
an ordinary function of type Rule m a ba -> 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 (
instance, for example. Instead, Rule m a)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.
Instances
| Monad m => ArrowKleisli m (Rule m) Source # | |
Defined in Hasura.Incremental.Internal.Rule | |
| MonadUnique m => ArrowCache m (Rule m) Source # | |
Defined in Hasura.Incremental.Internal.Cache | |
| Arrow (Rule m) Source # | |
| ArrowChoice (Rule m) Source # | |
| Profunctor (Rule m) Source # | |
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 # | |
| Strong (Rule m) Source # | |
| ArrowDistribute (Rule m) Source # | Unlike |
| Category (Rule m :: Type -> Type -> Type) Source # | |
| Functor (Rule m a) Source # | |
| Applicative (Rule m a) Source # | |
Defined in Hasura.Incremental.Internal.Rule | |
Constructors
| Result | |
Fields
| |
swapEither :: Either a b -> Either b a Source #
fromEither :: Either a a -> a 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
| ArrowDistribute (Rule m) Source # | Unlike |
| (Monoid w, ArrowDistribute arr) => ArrowDistribute (WriterA w arr) Source # | |