Skip to content

Conversation

Borgvall
Copy link
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
Copy link
Contributor

treeowl commented Jun 2, 2018

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
Copy link
Contributor Author

Borgvall commented Jun 9, 2018

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
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