Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-23 Thread Ryan Ingram
])) else do f (Roll (z ++ [throw])) --- On *Wed, 12/22/10, Ozgur Akgun ozgurak...@gmail.com* wrote: From: Ozgur Akgun ozgurak...@gmail.com Subject: Re: [Haskell-cafe] Why is Haskell flagging this? To: Ryan Ingram ryani.s...@gmail.com Cc: haskell-cafe@haskell.org, Daniel

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-22 Thread Ryan Ingram
leim...@gmail.comhttp://mc/compose?to=leim...@gmail.com * wrote: From: David Leimbach leim...@gmail.comhttp://mc/compose?to=leim...@gmail.com Subject: Re: [Haskell-cafe] Why is Haskell flagging this? To: michael rice nowg...@yahoo.comhttp://mc/compose?to=nowg...@yahoo.com Cc

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-22 Thread Daniel Fischer
On Wednesday 22 December 2010 12:03:01, Ryan Ingram wrote: Huh, that's weird, I just copy and pasted this into a new file and it worked for me. As a guess, you have mtl-1.*? In mtl-2.*, State s is made a type synonym for StateT s Identity, so there's no longer a data constructor State.

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-22 Thread Ryan Ingram
Interesting. In that case, state f = StateT $ \s - Identity (f s) allows state to replace State in that code. On Wed, Dec 22, 2010 at 4:56 AM, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: On Wednesday 22 December 2010 12:03:01, Ryan Ingram wrote: Huh, that's weird, I just copy and

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-22 Thread Ozgur Akgun
see also: http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Monad-State-Lazy.html#v:state On 22 December 2010 20:02, Ryan Ingram ryani.s...@gmail.com wrote: Interesting. In that case, state f = StateT $ \s - Identity (f s) allows state to replace State in that code.

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-22 Thread michael rice
]))   else do f (Roll (z ++ [throw])) --- On Wed, 12/22/10, Ozgur Akgun ozgurak...@gmail.com wrote: From: Ozgur Akgun ozgurak...@gmail.com Subject: Re: [Haskell-cafe] Why is Haskell flagging this? To: Ryan Ingram ryani.s...@gmail.com Cc: haskell-cafe@haskell.org, Daniel Fischer daniel.is.fisc

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-21 Thread Ryan Ingram
/10, David Leimbach leim...@gmail.com* wrote: From: David Leimbach leim...@gmail.com Subject: Re: [Haskell-cafe] Why is Haskell flagging this? To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org, Daniel Fischer daniel.is.fisc...@googlemail.com Date: Friday, December 17, 2010, 7

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-21 Thread michael rice
/21/10, Ryan Ingram ryani.s...@gmail.com wrote: From: Ryan Ingram ryani.s...@gmail.com Subject: Re: [Haskell-cafe] Why is Haskell flagging this? To: michael rice nowg...@yahoo.com Cc: David Leimbach leim...@gmail.com, Daniel Fischer daniel.is.fisc...@googlemail.com, haskell-cafe@haskell.org Date

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-21 Thread michael rice
Ingram ryani.s...@gmail.com Subject: Re: [Haskell-cafe] Why is Haskell flagging this? To: michael rice nowg...@yahoo.com Cc: David Leimbach leim...@gmail.com, Daniel Fischer daniel.is.fisc...@googlemail.com, haskell-cafe@haskell.org Date: Tuesday, December 21, 2010, 7:00 PM First, let's make some

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-18 Thread Christopher Wilson
On Fri, Dec 17, 2010 at 11:04 AM, michael rice nowg...@yahoo.com wrote: I don't understand this error message. Haskell appears not to understand that 1 is a Num. Prelude :t 1 1 :: (Num t) = t Prelude :t [1,2,3,4,5] [1,2,3,4,5] :: (Num t) = [t] Prelude Michael === f

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-18 Thread aditya siram
I think it is giving you the error because you the fmap in your code is operating on the IO monad and not the List monad. In order to get it to work, you can remove the IO layer with = as below: f :: [Int] - IO [Int] f lst = do return lst main = do let lst = f [1,2,3,4,5] lst = return

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-18 Thread Antoine Latter
This is a bit tricky. The type of 'f' is '[Int] - IO [Int]', which means that the type of 'lst' is 'IO [Int]'. So fmap (+1) tries to add one to the [Int] underneath the 'IO' type constructor. You can either use two 'fmap's, the first to lift up to IO and the second to lift into the list, or you

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-18 Thread Mads Lindstrøm
Hi Michael The type of lst is IO [Int] and therefore fmap (+1) applies (+1) to the hole lists of integers, and not to each member of the list. That is: fmap (+1) lst = fmap (+1) (return [1,2,3,4,5]) = return ([1,2,3,4,5] + 1) and you cannot say [1,2,3,4,5] + 1. Does that make sense? Maybe

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-18 Thread aditya siram
To make that a little clearer, here is code that uses two calls to fmap to drill through two monadic layers: f :: [Int] - IO [Int] f lst = do return lst main = do let lst = f [1,2,3,4,5] fmap (fmap (+1)) lst So the order of operations is : 1. The first fmap converts an IO [Int] to

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-18 Thread David Leimbach
On Fri, Dec 17, 2010 at 9:04 AM, michael rice nowg...@yahoo.com wrote: I don't understand this error message. Haskell appears not to understand that 1 is a Num. Prelude :t 1 1 :: (Num t) = t Prelude :t [1,2,3,4,5] [1,2,3,4,5] :: (Num t) = [t] Prelude Michael === f ::

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-18 Thread Daniel Peebles
Write out more types and it'll get more clear. f is [Int] - IO [Int] lst is f applied to Num a = [a], so it is of type IO [Int] fmap is applied to lst, which means it's stepping inside the IO. That means it's applying +1 to [1,2,3,4,5], which doesn't make much sense unless you have a Num

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-18 Thread Christopher Done
On 17 December 2010 18:04, michael rice nowg...@yahoo.com wrote: === f :: [Int] - IO [Int] f lst = do return lst main = do let lst = f [1,2,3,4,5] fmap (+1) lst The problem is that you are applying fmap to a type IO a. fmap (+1) (return [1,2,3]) But to achieve

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-18 Thread Thomas Davie
On 17 Dec 2010, at 21:44, Christopher Done wrote: On 17 December 2010 18:04, michael rice nowg...@yahoo.com wrote: === f :: [Int] - IO [Int] f lst = do return lst main = do let lst = f [1,2,3,4,5] fmap (+1) lst The problem is that you are applying fmap to

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-18 Thread David Leimbach
stumped by something simple like this, but that's how one learns. Thanks again, Michael --- On Fri, 12/17/10, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: From: Daniel Fischer daniel.is.fisc...@googlemail.com Subject: Re: [Haskell-cafe] Why is Haskell flagging

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-17 Thread Darrin Chandler
On Fri, Dec 17, 2010 at 09:04:20AM -0800, michael rice wrote: I don't understand this error message. Haskell appears not to understand that 1 is a Num. Prelude :t 1 1 :: (Num t) = t Prelude :t [1,2,3,4,5] [1,2,3,4,5] :: (Num t) = [t] Prelude Michael === f ::

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-17 Thread Miguel Mitrofanov
On 17 Dec 2010, at 20:04, michael rice wrote: I don't understand this error message. Haskell appears not to understand that 1 is a Num. As it clearly states in the error message, it doesn't understand that [Int] is a Num - and it's not. No instance for Num something usually indicates that

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-17 Thread michael rice
like this, but that's how one learns. Thanks again, Michael --- On Fri, 12/17/10, Daniel Fischer daniel.is.fisc...@googlemail.com wrote:     From: Daniel Fischer daniel.is.fisc...@googlemail.com     Subject: Re: [Haskell-cafe] Why is Haskell flagging this?     To: haskell-cafe@haskell.org

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-17 Thread michael rice
...@gmail.com wrote: From: David Leimbach leim...@gmail.com Subject: Re: [Haskell-cafe] Why is Haskell flagging this? To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org, Daniel Fischer daniel.is.fisc...@googlemail.com Date: Friday, December 17, 2010, 7:45 PM No problem.  Haskell is a different

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-17 Thread Daniel Fischer
On Friday 17 December 2010 18:04:20, michael rice wrote: I don't understand this error message. Haskell appears not to understand that 1 is a Num. Prelude :t 1 1 :: (Num t) = t Prelude :t [1,2,3,4,5] [1,2,3,4,5] :: (Num t) = [t] Prelude Michael === f :: [Int] - IO