[Haskell-cafe] Type problem
Thomas Davie
tom.davie at gmail.com
Sat Feb 26 21:22:49 CET 2011
Because applying f to the list is not the same thing is applying bind to the list and f.
Bob
On 26 Feb 2011, at 20:17, michael rice wrote:
> Why? Shouldn't this work for any type a?
>
> Michael
>
> ==========
>
> f :: [a] -> [a]
> f l = do x <- l
> return x
>
> ==========
>
> *Main> :r
> [1 of 1] Compiling Main ( test.hs, interpreted )
> Ok, modules loaded: Main.
> *Main> f "abcde"
> "abcde"
> *Main> f [1,2,3,4,5]
> [1,2,3,4,5]
> *Main> "abcde" >>= f
>
> <interactive>:1:12:
> Couldn't match expected type `Char' against inferred type `m b'
> In the second argument of `(>>=)', namely `f'
> In the expression: "abcde" >>= f
> In the definition of `it': it = "abcde" >>= f
> *Main>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110226/38b97f38/attachment.htm>
More information about the Haskell-Cafe
mailing list