Skip to content

Provide functions to sequence evaluations relative to io actions - #3

Merged
simonmar merged 4 commits into
haskell:masterfrom
Borgvall:runEvalIO
Jun 11, 2018
Merged

simonmar merged 4 commits into
haskell:masterfrom
Borgvall:runEvalIO

Conversation

@Borgvall

Copy link
Copy Markdown
Contributor

This is my way to fix issue #1.

It is occasionally usefull, to run evaluations at a specific time
relative to IO actions. However, 'runEval' defers the evaluation until
its result is actually needed. This makes it difficult to reason about,
if or when the evaluation is performed.

add usingIO and withStrategyIO
@treeowl

treeowl commented Jun 2, 2018

Copy link
Copy Markdown
Contributor

I think this is a good idea, but I'm not convinced we need all three functions. On the flip side, we should probably also offer

stToEval :: (forall s. ST s a) -> Eval a

@Borgvall

Borgvall commented Jun 9, 2018

Copy link
Copy Markdown
Contributor Author

Technically one needs only runEvalIO. Then the other two functions can be easily defined using the public interface. I just provided them, to be symmetric with runEval, withStrategy and using. Typical usecases might look like this:

do   ...
     x <- expression `usingIO` strat
     y <- withStrategyIO strat2 . f . g $ x
     runEvalIO $ do
        ...

In my testings I never encountered a case, where withStrategyIO actually seems useful though. So it might can be droped.

stToEval might be useful. One might create a feature request with an usecase.

The merge was necessary, because the internal implementation of `Eval`
has changed.
@simonmar

Copy link
Copy Markdown
Member

This looks OK to me, I'll go ahead and merge. Thanks for adding the test!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants