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.Sink.Internal.Class

  • 1 class
  • 1 value
classclass Monad m => HasSink (tag :: k) a (m :: Type -> Type) | tag m -> a where
#

Sinking capability.

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

Methods

  • yield_ :: Proxy# tag -> a -> m ()

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

Instances17HasSink, Reified, …
  • HasSink tag (DList a) m => HasSink tag a (SinkDList m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies

    This instance may seem a bit odd at first. All it does is wrap each yielded value in a single element difference list. How does re-yielding something else constitute a strategy for implementing HasSink in the first place? The answer is that difference lists form a monoid, which allows a second stragegy to be used which accumulates all yields in a single value, actually eliminating the HasSink constraint this time.

    SinkLog below in fact does this, so the easiest way to fully eliminate the HasSink constraint as described above is:

    deriving (HasSink tag w) via
      SinkDList (SinkLog (MonadState SomeStateMonad))
  • HasState tag [a] m => HasSink tag a (SinkStack m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies
  • MonadState s m => HasSink tag s (MonadState m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies · orphan
  • (HasSink tag a m, MonadTrans t, Monad (t m)) => HasSink tag a (Lift (t m))Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies · orphan

    Lift one layer in a monad transformer stack.

    Note, that if the HasSink instance is based on HasState, then it is more efficient to apply Lift to the underlying state capability. E.g. you should favour

    deriving (HasSink tag w) via
      SinkLog (Lift (SomeTrans (MonadState SomeStateMonad)))

    over

    deriving (HasSink tag w) via
      Lift (SomeTrans (SinkLog (MonadState SomeStateMonad)))
  • (Monoid w, HasState tag w m) => HasSink tag w (SinkLog m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies
  • (MutableRef ref, RefElement ref ~ s, HasSource tag ref m, PrimMonad m, PrimState m ~ MCState ref) => HasSink tag s (ReaderRef m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies · orphan
  • Monad m => HasSink tag a (Stream (Of a) m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies · orphan
  • (HasSource tag (IORef s) m, MonadIO m) => HasSink tag s (ReaderIORef m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies · orphan
  • (Coercible from to, HasSink tag from m) => HasSink tag to (Coerce to m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies · orphan

    Convert the state using safe coercion.

  • HasSink oldtag s m => HasSink newtag s (Rename oldtag m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies · orphan

    Rename the tag.

  • (forall x. Coercible (m x) (t2 (t1 m) x), Monad m, HasSink tag a (t2 (t1 m))) => HasSink tag a ((:.:) t2 t1 m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies · orphan

    Compose two accessors.

  • (Monad m, Reifies s (Reified tag (HasSink tag a) m)) => HasSink tag a (Reflected s (HasSink tag a) m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Class
  • (Monad m, Reifies s' (Reified tag (HasState tag s) m)) => HasSink tag s (Reflected s' (HasState tag s) m)Defined in capability-0.5.0.1 · Capability.State.Internal.Class
  • (Monoid w, Monad m, Reifies s (Reified tag (HasWriter tag w) m)) => HasSink tag w (Reflected s (HasWriter tag w) m)Defined in capability-0.5.0.1 · Capability.Writer
  • (tag ~ field, HasField' field record v, HasState oldtag record m) => HasSink tag v (Field field oldtag m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies · orphan

    Zoom in on the record field field of type v in the state record.

  • (tag ~ pos, HasPosition' pos struct v, HasState oldtag struct m) => HasSink tag v (Pos pos oldtag m)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Strategies · orphan

    Zoom in on the field at position pos of type v in the state struct.

  • data Reified tag (HasSink tag a)Defined in capability-0.5.0.1 · Capability.Sink.Internal.Class
valueyield :: HasSink tag a m => a -> m ()
#

yield @tag a emits a in the sink capability tag.