Skip to content

send :: (forall x. (a -> Free f x) -> f (Free f x)) -> Codensity (Free f) a #75

@Icelandjack

Description

@Icelandjack

I was reading Oleg's Extensible Effects: An Alternative to Monad Transformers.

The coroutine for arbitrary effects Eff r is the same as Codensity (Free r).

data VE w r = Val w | E (r (VE w r))

newtype Eff r a = Eff{runEff ::  w. (a  VE w r)  VE w r}

So I wondered if the send function had some usefulness in the library, admin is already a specialization of lowerCodensity

send :: ( w. (a  VE w r)  r (VE w r))  Eff r a
send f = Eff $ \k  E (f k)

admin :: Eff r w  VE w r
admin (Eff m) = m Val

but send, producing a Codensity (Free f) a, is not in the library:

send :: (forall x. (a -> Free f x) -> f (Free f x)) -> Codensity (Free f) a
send eff = Codensity \next -> Free (eff next)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions