Skip to content

Allow sequencing evaluations relative to io actions #1

Description

@Borgvall

It is sometimes useful to sequence the evaluation relative to IO actions. For instance one might spark a computation in parallel, while the main thread is waiting for further input.

I have written a (ghc only) patch that provides functions that allow this (Borgvall@3d5b0fb). You might consider merging it.

The downside is, it depends on the internal representation of IO and Eval, and adds functions to the external interface.

Activity

  1. Borgvall commented on Jan 22, 2015

    @Borgvall
    ContributorAuthor

    I have added a test for runEvalIO (Borgvall@7ee1026) and implement it using the classic Eval implementation using Done (Borgvall@563bb87).

  2. treeowl commented on Aug 22, 2015

    @treeowl
    Contributor

    I think there's a much simpler way to accomplish this in vaguely recent compiler versions:

    {-# Language GeneralizedNewtypeDeriving #-}
    newtype Eval a = Eval (IO a) deriving (Functor, Applicative, Monad)
    runEval (Eval m) = unsafePerformIO m

    Exposing the newtype constructor from an "internals" module would give users maximal flexibility, but barring that, exposing wrapping and unwrapping functions seems reasonable.

  3. Borgvall commented on Sep 1, 2015

    @Borgvall
    ContributorAuthor

    If you propose to change the internal implementation of Eval, please open a new issue. It would have a much greater impact, and needs broader discussions.

    I think, that sequencing evaluations relative to io actions should be part of the external interface.

    The reverse (IO -> Eval) would break the basic idea of the parallel package!

  4. Borgvall commented on Jun 15, 2018

    @Borgvall
    ContributorAuthor

    Fixed by the merge of #3.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions