[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?



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"
*Main> f [1,2,3,4,5]
*Main> "abcde" >>= f

    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

-------------- 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