HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulecapability-0.5.0.1Haskell2010

Capability.Source.Internal.Class

Defines a capability for computations that consume a stream of values as part of their execution.

Programs comsuming streams of data are common. Examples: rolling up input events. Sources are similar to Python generators.

This can be thought of as a reader capability where there's no guarantee that one reads the same value each time.

The HasSource capability enables separating the logic responsible for emitting events from that responsible for collecting or handling them. The name is because a source is needed to produce the locally consumed stream.

  • 1 class
  • 2 values
classclass Monad m => HasSource (tag :: k) a (m :: Type -> Type) | tag m -> a where
#

Sourcing capability.

An instance does not need to fulfill any additional laws besides the monad laws.

Methods

  • await_ :: Proxy# tag -> m a

    For technical reasons, this method needs an extra proxy argument. You only need it if you are defining new instances of HasSource. Otherwise, you will want to use await. See await for more documentation.

Instances16HasSource, Reified, …
  • HasState tag r m => HasSource tag r (ReadStatePure m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies
  • MonadReader r m => HasSource tag r (MonadReader m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies
  • MonadState s m => HasSource tag s (MonadState m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies · orphan
  • (HasSource tag r m, MonadTrans t, Monad (t m)) => HasSource tag r (Lift (t m))Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies · orphan
  • (HasState tag r m, MonadMask m) => HasSource tag r (ReadState m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies
  • (MutableRef ref, RefElement ref ~ s, HasSource tag ref m, PrimMonad m, PrimState m ~ MCState ref) => HasSource tag s (ReaderRef m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies · orphan
  • (HasSource tag (IORef s) m, MonadIO m) => HasSource tag s (ReaderIORef m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies · orphan
  • (Coercible from to, HasSource tag from m, forall x y. Coercible x y => Coercible (m x) (m y)) => HasSource tag to (Coerce to m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies · orphan
  • HasSource oldtag r m => HasSource newtag r (Rename oldtag m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies · orphan

    Rename the tag.

  • (forall x. Coercible (m x) (t2 (t1 m) x), Monad m, HasSource tag r (t2 (t1 m))) => HasSource tag r ((:.:) t2 t1 m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies · orphan
  • (Monad m, Reifies s (Reified tag (HasReader tag r) m)) => HasSource tag r (Reflected s (HasReader tag r) m)Defined in capability-0.5.0.1 · Capability.Reader.Internal.Class
  • (Monad m, Reifies s (Reified tag (HasSource tag a) m)) => HasSource tag a (Reflected s (HasSource tag a) m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Class
  • (Monad m, Reifies s' (Reified tag (HasState tag s) m)) => HasSource tag s (Reflected s' (HasState tag s) m)Defined in capability-0.5.0.1 · Capability.State.Internal.Class
  • (tag ~ field, HasField' field record v, HasSource oldtag record m) => HasSource tag v (Field field oldtag m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies · orphan
  • (tag ~ pos, HasPosition' pos struct v, HasSource oldtag struct m) => HasSource tag v (Pos pos oldtag m)Defined in capability-0.5.0.1 · Capability.Source.Internal.Strategies · orphan
  • data Reified tag (HasSource tag a)Defined in capability-0.5.0.1 · Capability.Source.Internal.Class
valueawait :: HasSource tag a m => m a
#

await @tag a takes a from the source capability tag.

valueawaits :: HasSource tag r m => (r -> a) -> m a
#

awaits @tag retrieves the image by f of the environment of the source capability tag.

Property
awaits @tag f = f <$> await @tag