[Haskell-cafe] Monads and scope

Mike Meyer mwm at mired.org
Tue Nov 4 04:08:30 UTC 2014


On Nov 3, 2014 9:15 PM, "Brandon Allbery" <allbery.b at gmail.com> wrote
> On Mon, Nov 3, 2014 at 10:02 PM, Jeffrey Brown <jeffbrown.the at gmail.com>
wrote:
>> Stated differently: Monadic code can call pure code. Can pure code ever
call monadic code?
> Something like runReaderT or runST? Or in the extreme case,
unsafePerformIO --- which is unsafe for a reason, and trying to use it to
sneak into IO from pure code will usually cause major problems, because
pure code does not expect non-deterministic results. Otherwise, the type
system does its best to avoid you unexpectedly dipping into e.g. IO from
inside pure code.

To be more general, the monad typeclass doesn't include an operation that
returns a value that doesn't have the type of the monad, so the answer in
general is no. Specific instances of the typeclass can have such
operations. Brandon gave some examples of those.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141103/0dd89d3f/attachment.html>


More information about the Haskell-Cafe mailing list