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

2010-08-10 Thread John Lato
On Tue, Aug 10, 2010 at 6:48 AM, Edward Z. Yang ezy...@mit.edu wrote: Excerpts from Luke Palmer's message of Tue Aug 10 01:04:04 -0400 2010: Except, of course, you want the signature   evalCont :: Cont r a - a Which is not possible.  But I am not sure where all this discussion is coming

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

2010-08-09 Thread John Lato
From: Alexey Khudyakov alexey.sklad...@gmail.com On Fri, 30 Jul 2010 09:29:59 +0200 Stefan Holdermans ste...@vectorfabrics.com wrote: No I think here we breaking out from _arbitrary_ monad. If monadic function works for every monad then it must work for identity monad too. Here is

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

2010-08-09 Thread Daniel Fischer
On Monday 09 August 2010 21:19:01, John Lato wrote: I don't find purify2 particularly helpful because I almost never want to break out of any arbitrary monad; I want to be able to break out of a specific monad without knowing which monad it is, that is: purify3 :: Monad m = m a - a purify3

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

2010-08-09 Thread Luke Palmer
On Mon, Aug 9, 2010 at 1:19 PM, John Lato jwl...@gmail.com wrote: I don't find purify2 particularly helpful because I almost never want to break out of any arbitrary monad; I want to be able to break out of a specific monad without knowing which monad it is, that is: purify3 :: Monad m = m a

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

2010-08-09 Thread Edward Z. Yang
Excerpts from Luke Palmer's message of Tue Aug 10 01:04:04 -0400 2010: Except, of course, you want the signature evalCont :: Cont r a - a Which is not possible. But I am not sure where all this discussion is coming from, Maybe and (r -) cannot be broken out of. Isn't that example

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

2010-07-31 Thread aditya siram
Each monad implementation is different. In the case of the State monad your 'execState' call extracts a non-monadic value. Of the basic monads I found the State monad the most confusing because of the complicated way in which it threads state through the computation. In the end, desugaring the

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

2010-07-30 Thread C K Kashyap
Hi, In the code here - http://hpaste.org/fastcgi/hpaste.fcgi/view?id=28393#a28393 If I look at the type of modifiedImage, its simply ByteString - but isn't it actually getting into and back out of the state monad? I am of the understanding that once you into a monad, you cant get out of it? Is

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

2010-07-30 Thread Lyndon Maydwell
You cannot break out of a monad if all you have available to use are the monad typeclass functions, however there is nothing preventing an instance from being created that allows escape. Many of these escape methods come in the form of runX functions, but you can use constructors to break out with

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

2010-07-30 Thread Jason Dagit
On Thu, Jul 29, 2010 at 11:48 PM, Lyndon Maydwell maydw...@gmail.comwrote: You cannot break out of a monad if all you have available to use are the monad typeclass functions, however there is nothing preventing an instance from being created that allows escape. Many of these escape methods

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

2010-07-30 Thread Stefan Holdermans
Jason, There is one case where you can break out of a monad without knowing which monad it is. Well, kind of. It's cheating in a way because it does force the use of the Identity monad. Even if it's cheating, it's still very clever and interesting. How is this cheating? Or better, how

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

2010-07-30 Thread Anton van Straaten
C K Kashyap wrote: In the code here - http://hpaste.org/fastcgi/hpaste.fcgi/view?id=28393#a28393 If I look at the type of modifiedImage, its simply ByteString - but isn't it actually getting into and back out of the state monad? I am of the understanding that once you into a monad, you cant

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

2010-07-30 Thread Tillmann Rendel
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

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

2010-07-30 Thread Martijn van Steenbergen
On 7/30/10 9:29, Stefan Holdermans wrote: Jason, There is one case where you can break out of a monad without knowing which monad it is. Well, kind of. It's cheating in a way because it does force the use of the Identity monad. Even if it's cheating, it's still very clever and

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

2010-07-30 Thread Martijn van Steenbergen
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

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

2010-07-30 Thread Ivan Lazar Miljenovic
Martijn van Steenbergen mart...@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

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

2010-07-30 Thread Stefan Holdermans
Martijn, 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. And that's only because, at least the runtime system allows for execution of a computation inside the IO monad at top-level. Cheers, Stefan

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

2010-07-30 Thread Alex Rozenshteyn
Here is my understanding with respect to the question. In the general case, you cannot come out of a monad, because the monad typeclass does not include any functions without of the form (m a - a). Also, as a category theoretic construct, a monad does not have to have an exit function. (caveat:

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

2010-07-30 Thread Jason Dagit
On Fri, Jul 30, 2010 at 12:29 AM, Stefan Holdermans ste...@vectorfabrics.com wrote: Jason, There is one case where you can break out of a monad without knowing which monad it is. Well, kind of. It's cheating in a way because it does force the use of the Identity monad. Even if it's

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

2010-07-30 Thread Alexey Khudyakov
On Fri, 30 Jul 2010 09:29:59 +0200 Stefan Holdermans ste...@vectorfabrics.com wrote: Jason, There is one case where you can break out of a monad without knowing which monad it is. Well, kind of. It's cheating in a way because it does force the use of the Identity monad. Even if it's

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

2010-07-30 Thread John Meacham
On Sat, Jul 31, 2010 at 01:49:43AM +0400, Alexey Khudyakov wrote: No I think here we breaking out from _arbitrary_ monad. If monadic function works for every monad then it must work for identity monad too. Here is simplest form of purify function: purify2 :: (forall m . Monad m = m a) - a

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

2010-07-30 Thread wren ng thornton
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. Indeed. The correct formulation of the statement is that it's not safe to leave a monad. Where safe has the same connotation as in all the unsafeFoo

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

2010-07-30 Thread wren ng thornton
Martijn van Steenbergen wrote: 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. You can escape IO just fine. Just compile your program, and then run it in the real life monad. Results aren't guaranteed to be the

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

2010-07-30 Thread wren ng thornton
Alex Rozenshteyn wrote: I also found myself thinking about list as a monad in terms of this discussion. I think it's an interesting case: it's pure, but it doesn't really make sense to come out of it. Head, indexing, and last all break out of it, but none of them can be the default, and all

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

2010-07-30 Thread Stefan Holdermans
Alexey, There is one case where you can break out of a monad without knowing which monad it is. Well, kind of. It's cheating in a way because it does force the use of the Identity monad. Even if it's cheating, it's still very clever and interesting. How is this cheating? Or better, how