Discussion: Can we make evaluate easier to find?

David Feuer david.feuer at gmail.com
Wed Jan 7 06:00:33 UTC 2015


I went ahead and tried this. It works like a charm, but there's one
minor wrinkle: it seems we'd have to move the declaration of the
PrimMonad class out of the primitive package and into base, perhaps
into GHC.Base, with the IO instance in GHC.Base and the ST instance in
GHC.ST. What do people think?

On Tue, Jan 6, 2015 at 11:36 PM, David Feuer <david.feuer at gmail.com> wrote:
> The evaluate function is defined in GHC.IO, and exported publicly by
> Control.Exception. This strikes me as an extremely strange place for
> it. Can we find another place to put it that would seem more sensible?
> I don't think it should be removed from Control.Exception, but rather
> that maybe it should be added somewhere else as well.
>
> Digging all around, I've come up with one idea that might work, if we
> give evaluate a more general type:
>
> evaluate :: PrimMonad m => a -> m a
> evaluate a = primitive (\s -> seq# a s)
>
> With this type, we could easily put it in Control.Monad.Primitive.
> There may be some challenges wiggling module dependencies around, but
> hopefully not huge ones.
>
> David


More information about the Libraries mailing list