[Haskell-cafe] Type problem
michael rice
nowgate at yahoo.com
Sat Feb 26 21:17:01 CET 2011
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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110226/6c468c13/attachment.htm>
More information about the Haskell-Cafe
mailing list