[Haskell-cafe] Can we come out of a monad?

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Fri Jul 30 07:25:36 EDT 2010


Martijn van Steenbergen <martijn at van.steenbergen.nl> writes:

> On 7/30/10 12:29, Tillmann Rendel wrote:
>> C K Kashyap wrote:
>>> I am of the
>>> understanding that once you into a monad, you cant get out of it?
>>
>> That's not correct.
>>
>> There are many monads, including Maybe, [], IO, ... All of these monads
>> provide operations (>>=), return and fail, and do notation implemented
>> in terms of these functions, as a common interface. Using just this
>> common interface, you cannot "get out of the monad".
>>
>> But most if not all monads also provide additional operations, specific
>> to the monad in question. Often, these operations can be used to "get
>> out of that monad". For example, with Maybe, you can use pattern matching:
>
> In fact, I would argue that a monad which you cannot escape from is
> not very useful at all. IO is the only exception I know of.

True; all other monads allow you to at least get into IO (STM, etc.).

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list