Sitelet https://github.com/purescript-halogen/purescript-halogen/issues/774
Skip to content

Possibility to unlift effectful computations in Halogen monad #774

Description

@Swordlash

Hi,

I have recently implemented a modification debouncing mechanism for components I use at work, and I had to approach a following well-known problem: how to run a function like setTimeout :: Int -> Effect Unit -> Effect TimeoutId in the context of a HalogenM monad? I managed to get around this issue by using subscriptions and notifying in the second argument, but I don't really like the idea of creating a separate component action (actually, needing to have a concrete component in hand at all) just to be able to perform some HalogenM action in the Effect monad and lift the result back to the HalogenM.

So HalogenM should be enhanced with something like the Haskell's withRunInIO. I believe it can be done somehow - from my understanding we interpret a HalogenM monad in Aff using a reference for keeping a state, which somehow resembles the ReaderT IO monads which can easily be unlifted in IO. I can happily try to implement this feature, should you decide its worth having.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions