[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

[Haskell-cafe] Fail to install SDL with Cabal

2010-07-30 Thread Eitan Goldshtrom
I'm trying to install SDL through Cabal -- I don't know another way to install it. However, I'm getting this: setup.exe: The package has a './configure' script. This requires a Unix compatibility toolchain such as MinGW+MSYS or Cygwin. cabal: Error: some packages failed to install: SDL-0.5.10

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

[Haskell-cafe] couchDB

2010-07-30 Thread Andrew U. Frank
a few weeks ago a question was posed on this list for examples how to use couchDB. i post the 'hello world' for couchDB using the haskell interface - perhaps it helps other to start! a more extensive and complicate example is found at www.maztravel.com/haskell/mySqlToCouchDB.html I created with

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

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

2010-07-30 Thread Kevin Jardine
The original poster states that the type of modifiedImage is simply ByteString but given that it calls execState, is that possible? Would it not be State ByteString? Kevin On Jul 30, 9:49 am, Anton van Straaten an...@appsolutions.com wrote: C K Kashyap wrote: In the code here -

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

2010-07-30 Thread Kevin Jardine
Oops, I should have written IO ByteString as the State stuff is only *inside* execState. But a monad none the less? Kevin On Jul 30, 9:59 am, Kevin Jardine kevinjard...@gmail.com wrote: The original poster states that the type of modifiedImage is simply ByteString but given that it calls

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

2010-07-30 Thread Kevin Jardine
Or is it possible to call a function in a monad and return a pure result? I think that is what the original poster was asking? I know that unsafePerformIO can do this, but I thought that was a bit of a hack. I'm still trying to understand how monads interact with types so I am interested in this

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

2010-07-30 Thread Anton van Straaten
On Jul 30, 9:59 am, Kevin Jardine kevinjard...@gmail.com wrote: The original poster states that the type of modifiedImage is simply ByteString but given that it calls execState, is that possible? Would it not be State ByteString? Oops, I should have written IO ByteString as the State

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

2010-07-30 Thread Kevin Jardine
I think that these are therefore the responses to the original questions: I am of the understanding that once you into a monad, you cant get out of it? You can run monadic functions and get pure results. So it looks like in that sense you can get out of it. Is this breaking the monad scheme?

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

2010-07-30 Thread Anton van Straaten
Kevin Jardine wrote: I think that these are therefore the responses to the original questions: I am of the understanding that once you into a monad, you cant get out of it? You can run monadic functions and get pure results. Some clarifications: First, many monads (including State) are

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

2010-07-30 Thread Kevin Jardine
I think that we are having a terminology confusion here. For me, a pure function is one that does not operate inside a monad. Eg. ++, map, etc. It was at one point my belief that although code in monads could call pure functions, code in pure functions could not call functions that operated

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

2010-07-30 Thread Daniel Díaz
I don't understand why to call impure to the types instances of a class. Monad is simply a class with their methods. Even the pure list is a monad. The only difference between Monad and other classes is do notation, and only affects notation. The impure side is a type, not a class: IO.

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

2010-07-30 Thread Ivan Lazar Miljenovic
Kevin Jardine kevinjard...@gmail.com writes: I think that we are having a terminology confusion here. For me, a pure function is one that does not operate inside a monad. Eg. ++, map, etc. No, a pure function is one without any side effects. It was at one point my belief that although code

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] Re: Can we come out of a monad?

2010-07-30 Thread Anton van Straaten
Kevin Jardine wrote: I think that we are having a terminology confusion here. For me, a pure function is one that does not operate inside a monad. Eg. ++, map, etc. Ivan Miljenovic has already given a good response, to which I'll only add this: I suspect that your idea of the meaning of

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

2010-07-30 Thread Kevin Jardine
So far the comments here only increase my confusion (which as I say, is not bad because it means that I am learning something!). As a Haskell newbie, the first thing I learned about monads is that they have a type signature that creates a kind of mud you can't wash off. eg. f :: String -

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

2010-07-30 Thread Colin Paul Adams
Kevin == Kevin Jardine kevinjard...@gmail.com writes: Kevin The more I learn about monads, however, the less I understand Kevin them. I've seen plenty of comments suggesting that monads Kevin are easy to understand, but for me they are not. I used to have the same problem. Then I

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

2010-07-30 Thread Ivan Lazar Miljenovic
Anton van Straaten an...@appsolutions.com writes: Ivan Miljenovic has already given a good response Why thank you, kind sir! /me bows I suspect that your idea of the meaning of purity came from over-generalization from the IO monad. IO actions may be impure, but that's not true of all

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

2010-07-30 Thread Ivan Lazar Miljenovic
Kevin Jardine kevinjard...@gmail.com writes: The more I learn about monads, however, the less I understand them. I've seen plenty of comments suggesting that monads are easy to understand, but for me they are not. How did you learn monads? More and more people seem to be getting away from

Re: [Haskell-cafe] Fail to install SDL with Cabal

2010-07-30 Thread Stephen Tetley
Hi Eitan You will probably need to do a manual install. If you download and extract the SDL binding there is a file - WIN32 - in the top level directory describing how to install on Windows. Unfortunately this file might now be out-of-date. I haven't used the Haskell SDL binding myself since

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

2010-07-30 Thread Brent Yorgey
On Fri, Jul 30, 2010 at 03:46:09AM -0700, Kevin Jardine wrote: When I plunged into Haskell earlier this year, I had no problem with understanding static typing, higher level functions and even separating pure functions from IO functions. The more I learn about monads, however, the less I

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

2010-07-30 Thread Kevin Jardine
On Jul 30, 1:11 pm, Brent Yorgey byor...@seas.upenn.edu wrote: Monads are hard to understand.  But they are *worth understanding*. That's the most inspiring and encouraging statement I've seen all week. Thanks! Kevin ___ Haskell-Cafe mailing list

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] Re: Can we come out of a monad?

2010-07-30 Thread Tillmann Rendel
Hi, I wrote: There is nothing special about monads! Kevin Jardine wrote: I've seen plenty of comments suggesting that monads are easy to understand, but for me they are not. My point was that monads are not a language feature whith special treatment of the compiler, but more like a design

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

2010-07-30 Thread Anton van Straaten
Kevin Jardine wrote: As a Haskell newbie, the first thing I learned about monads is that they have a type signature that creates a kind of mud you can't wash off. There are places where you can't wash it off, and places where you can. eg. f :: String - MyMonad String By mentioning the

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] Fail to install SDL with Cabal

2010-07-30 Thread Job Vranish
You might try emailing the maintainer directly. The package appears to be actively maintained. - Job On Fri, Jul 30, 2010 at 3:17 AM, Eitan Goldshtrom thesource...@gmail.comwrote: I'm trying to install SDL through Cabal -- I don't know another way to install it. However, I'm getting this:

Re: [Haskell-cafe] [Yi Editor]Cabal Problem

2010-07-30 Thread Job Vranish
I think you can just install the windows gtk dev libraries from here: http://www.gtk.org/download.html - Job On Thu, Jul 29, 2010 at 5:20 PM, Alessandro Stamatto astama...@gmail.comwrote: Installing Yi Editor i get the following error: --

Re: [Haskell-cafe] couchDB

2010-07-30 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 7/30/10 03:31 , Andrew U. Frank wrote: ps: if there is a better place to document examples? a wiki on haskell.org would be nice and should be available for any project in hackage. haskell.org has (more precisely, *is*) a wiki; request an

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

2010-07-30 Thread Ertugrul Soeylemez
Hello, it's a bit hidden in Haskell, but a monad instance consists of three functions: fmap :: (a - b) - (m a - m b) return :: a - m a join :: m (m a) - m a Nothing more is needed to define a monad. In Haskell, a monad is expressed by 'return' and (=) instead, but this is equivalent.

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

2010-07-30 Thread Ivan Lazar Miljenovic
Ertugrul Soeylemez e...@ertes.de writes: Hello, it's a bit hidden in Haskell, but a monad instance consists of three functions: fmap :: (a - b) - (m a - m b) You don't even need fmap defined for it to be a monad, since fmap f m = liftM f m = m = (return . f) -- Ivan Lazar Miljenovic

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

2010-07-30 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 7/30/10 06:06 , Kevin Jardine wrote: I think that we are having a terminology confusion here. For me, a pure function is one that does not operate inside a monad. Eg. ++, map, etc. It was at one point my belief that although code in monads

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] Re: Can we come out of a monad?

2010-07-30 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 7/30/10 11:48 , Ivan Lazar Miljenovic wrote: Ertugrul Soeylemez e...@ertes.de writes: it's a bit hidden in Haskell, but a monad instance consists of three functions: fmap :: (a - b) - (m a - m b) You don't even need fmap defined for it

Re: [Haskell-cafe] OpenGL Speed!

2010-07-30 Thread Henning Thielemann
Vo Minh Thu schrieb: There other possibilities to deal with raster graphics: - Use gtk; i.e. something like http://hackage.haskell.org/package/AC-EasyRaster-GTK - Output the data in some image format (if you want to do it yourself, the most simple is PPM) - Use X11 directly (if you're on

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

2010-07-30 Thread Jason Catena
On Jul 30, 11:17 am, Anton van Straaten wrote: Prelude :m Control.Monad.State Prelude Control.Monad.State let addToState :: Int - State Int (); addToState x = do s - get; put (s+x) Prelude Control.Monad.State let mAdd4 = addToState 4 Prelude Control.Monad.State :t mAdd4 m :: State Int ()

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] OpenGL Speed!

2010-07-30 Thread Henning Thielemann
On Fri, 30 Jul 2010, Eitan Goldshtrom wrote: HGL actually looks like EXACTLY what I need. I only need to set pixels, which looks like just what HGL would be good at. Only problem is that I can't find a single tutorial for HGL. Does anyone know or any, or where I could find one? I found the

Re: [Haskell-cafe] OpenGL Speed!

2010-07-30 Thread Eitan Goldshtrom
HGL actually looks like EXACTLY what I need. I only need to set pixels, which looks like just what HGL would be good at. Only problem is that I can't find a single tutorial for HGL. Does anyone know or any, or where I could find one? -Eitan On 7/30/2010 12:22 PM, Henning Thielemann wrote:

[Haskell-cafe] Definition of List type?

2010-07-30 Thread michael rice
From: Data.Maybe Description The Maybe type, and associated operations. From: Data.List Description Operations on lists. One description has the type and associated operations, the other only has the operations. Where can I find the type definition for List, and why isn't it in Data.List?

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread Edward Z. Yang
Excerpts from michael rice's message of Fri Jul 30 14:41:44 -0400 2010: One description has the type and associated operations, the other only has the operations. Where can I find the type definition for List, and why isn't it in Data.List? Hello Michael, This is because the List datatype

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread Gregory Crosswhite
List are actually built in to the language, but they are roughly equivalent to the following definition: data List a = [] | a:List a The reason why this definition never actually appears is because it defines the constructors using operators rather than names, which is not allowed in

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread Edward Z. Yang
Excerpts from Edward Z. Yang's message of Fri Jul 30 14:48:34 -0400 2010: Const x xs is x:xs (constructor) That should be a Cons, not Const. :o) Cheers, Edward ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread Ben Millwood
On Fri, Jul 30, 2010 at 7:50 PM, Gregory Crosswhite gcr...@phys.washington.edu wrote: The reason why this definition never actually appears is because it defines the constructors using operators rather than names, which is not allowed in vanilla Haskell.  (There is an extension,

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread michael rice
Thanks all, Now that I have a (very) rudimentary understanding of Haskell, I figured I'd back up and have a closer (conceptual) look at type definitions to see what they have in common, and just happen to pick Maybe and List. I also noticed Maybe has a list of Instances Monad Maybe Functor

[Haskell-cafe] using the orc library

2010-07-30 Thread Günther Schmidt
Hello, I'd like to download 1,000 web pages with up to 6 six concurrent downloads at a time. How can I express such a thread limit within the orc EDSL? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread Ben Millwood
On Fri, Jul 30, 2010 at 8:54 PM, michael rice nowg...@yahoo.com wrote: Thanks all, Now that I have a (very) rudimentary understanding of Haskell, I figured I'd back up and have a closer (conceptual) look at type definitions to see what they have in common, and just happen to pick Maybe and

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread Daniel Fischer
On Friday 30 July 2010 21:54:20, michael rice wrote: Thanks all, Now that I have a (very) rudimentary understanding of Haskell, I figured I'd back up and have a closer (conceptual) look at type definitions to see what they have in common, and just happen to pick Maybe and List. I also

[Haskell-cafe] Problem with haskell types

2010-07-30 Thread Anupam Jain
Hi, I am having trouble getting a small program to compile. The helpful folks at #haskell created a version of the program that does compile - http://hpaste.org/fastcgi/hpaste.fcgi/view?id=28406#a28408 but it is not very clear to them (and to me) why the original program wouldn't type compile in

[Haskell-cafe] Announce type-level-natural-number-1.0: Simple, Haskell 2010-compatible type level natural numbers

2010-07-30 Thread Gregory Crosswhite
Hey everyone, I am pleased to announce the release of the type-level-natural-number package, which implements natural numbers at the type level. Although there are many packages on Hackage that implement type level natural numbers, this package is distinguished by its simplicity: it does not

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread michael rice
Hi Daniel, OK, now I'm getting somewhere. I was looking here: http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0.0/Data-Maybe.html instead of in the source. Seem to be on the right track. I'm going to do some more poking around. Thanks a lot, guys. Michael --- On Fri, 7/30/10,

Re: [Haskell-cafe] Problem with haskell types

2010-07-30 Thread roconnor
I was one of the people on #haskell discussing this with Anupam. Note that that when you remove the signature of d, the result complies and ghci will state the inferred type of d is exactly the signature that you are not allowed to write. In my opinion, this is a bug in the Haskell 98 report

Re: [Haskell-cafe] Announce type-level-natural-number-1.0: Simple, Haskell 2010-compatible type level natural numbers

2010-07-30 Thread Alexey Khudyakov
On Fri, 30 Jul 2010 13:28:19 -0700 Gregory Crosswhite gcr...@phys.washington.edu wrote: Hey everyone, I am pleased to announce the release of the type-level-natural-number package, which implements natural numbers at the type level. Although there are many packages on Hackage that

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] using the orc library

2010-07-30 Thread Edward Z. Yang
Excerpts from Günther Schmidt's message of Fri Jul 30 16:16:38 -0400 2010: I'd like to download 1,000 web pages with up to 6 six concurrent downloads at a time. How can I express such a thread limit within the orc EDSL? One solution that comes to mind is place all 1000 web pages in an MVar

[Haskell-cafe] Microsoft's Singularity Project and Haskell

2010-07-30 Thread Vasili I. Galchin
Hello, In the latest ACM CACM is a paper on Singularity. Here also is an overview: http://lambda-the-ultimate.org/node/1081. I haven't finished the CACM paper yet but I only mention of languages like C# and F#. Singularity is predicated around providing a safe environment. IMO Haskell is even

Re: [Haskell-cafe] Announce type-level-natural-number-1.0: Simple, Haskell 2010-compatible type level natural numbers

2010-07-30 Thread John Meacham
On Sat, Jul 31, 2010 at 01:32:50AM +0400, Alexey Khudyakov wrote: The envisioned use case is for annotating types with natural numbers, so that extra functionality such as addition and subtraction of natural numbers is unnecessary. Nothing is stopping someone from implementing this

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] Re: Re: Can we come out of a monad?

2010-07-30 Thread John Meacham
On Fri, Jul 30, 2010 at 11:57:00AM -0500, Jason Catena wrote: By this example State doesn't seem to give you anything more than a closure would, since it doesn't act like much of an accumulator (by, for example, storing 6 as its new internal value). Could you use State for something like

Re: [Haskell-cafe] Problem with haskell types

2010-07-30 Thread Job Vranish
Yeah I recently ran into this myself. ( http://osdir.com/ml/haskell-cafe@haskell.org/2010-07/msg00020.html). It's not a bug, just a limitation of haskell's inference algorithm for mutually recursive groups of functions. The problem is that haskell infers groups (the strongly connected components)

Re: [Haskell-cafe] Announce type-level-natural-number-1.0: Simple, Haskell 2010-compatible type level natural numbers

2010-07-30 Thread John Meacham
Heh. I was just thinking I needed type level naturals last night at the pub. I wanted to support gcc's vector type extension in jhc http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html which allow diretly expressing vector operations that use the SIMD features of modern CPUS, I didn't want

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] Re: Can we come out of a monad?

2010-07-30 Thread wren ng thornton
Ivan Lazar Miljenovic wrote: More and more people seem to be getting away from trying to say that monads are containers/burritos/etc. and just teaching them by way of the definition, either = and return or just join You always need return. The choice of primitives is: return, (=) or:

[Haskell-cafe] dear traversable

2010-07-30 Thread Ben
dear traversable geniuses -- i am looking for better implementations of unzipMap :: M.Map a (b, c) - (M.Map a b, M.Map a c) unzipMap m = (M.map fst m, M.map snd m) unliftMap :: (Ord a) = M.Map a (b - c) - M.Map a b - M.Map a c unliftMap mf ma = M.mapWithKey (\k v - mf M.! k $ v) ma the first

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] dear traversable

2010-07-30 Thread John Meacham
On Fri, Jul 30, 2010 at 08:13:43PM -0700, Ben wrote: unliftMap :: (Ord a) = M.Map a (b - c) - M.Map a b - M.Map a c unliftMap mf ma = M.mapWithKey (\k v - mf M.! k $ v) ma I always thought a useful map primitive would be unionWithJoin :: (a - b - c) -- combine values that appear in both

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] Re: Can we come out of a monad?

2010-07-30 Thread wren ng thornton
Brandon S Allbery KF8NH wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 7/30/10 11:48 , Ivan Lazar Miljenovic wrote: Ertugrul Soeylemez e...@ertes.de writes: it's a bit hidden in Haskell, but a monad instance consists of three functions: fmap :: (a - b) - (m a - m b) You don't

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

2010-07-30 Thread wren ng thornton
Jason Catena wrote: By this example State doesn't seem to give you anything more than a closure would, since it doesn't act like much of an accumulator (by, for example, storing 6 as its new internal value). Reader r = (r-) Writer m = Monoid m = (m,) State s = (s-) . (s,) So, yes, the state

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread wren ng thornton
Ben Millwood wrote: On Fri, Jul 30, 2010 at 7:50 PM, Gregory Crosswhite gcr...@phys.washington.edu wrote: The reason why this definition never actually appears is because it defines the constructors using operators rather than names, which is not allowed in vanilla Haskell. (There is an

[Haskell-cafe] Re: Microsoft's Singularity Project and Haskell

2010-07-30 Thread Vasili I. Galchin
Probably a more poignant question would be a comparison of Haskell's type system and Sing#'s (http://en.wikipedia.org/wiki/Sing_sharp). Vasili On Fri, Jul 30, 2010 at 5:19 PM, Vasili I. Galchin vigalc...@gmail.comwrote: Hello, In the latest ACM CACM is a paper on Singularity. Here also

Re: [Haskell-cafe] dear traversable

2010-07-30 Thread wren ng thornton
Ben wrote: unliftMap :: (Ord a) = M.Map a (b - c) - M.Map a b - M.Map a c unliftMap mf ma = M.mapWithKey (\k v - mf M.! k $ v) ma the first is obviously inefficient as it traverses the map twice. the second just seems like it is some kind of fmap. It's the (*) operator of Applicative, which

Re: [Haskell-cafe] dear traversable

2010-07-30 Thread wren ng thornton
Ben wrote: dear traversable geniuses -- i am looking for better implementations of unzipMap :: M.Map a (b, c) - (M.Map a b, M.Map a c) unzipMap m = (M.map fst m, M.map snd m) I don't think you can give a more efficient implementation using the public interface of Data.Map. You need to have

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