[Haskell-beginners] foldM with tuple and maybe
David McBride
toad3k at gmail.com
Tue Dec 31 00:01:44 UTC 2013
You have a foldM function which takes a " a -> b -> m a " as a first
argument. But you are passing it f1 which has a type (a, b) -> m a.
Unfortunately I'm not sure what you were trying to do. The function
you have just doesn't fit. :(
Maybe you intended to have f1 :: String -> (String, String) -> IO
String, and then go
:t foldM f1 "" x
foldM f1 "" [("a","b"),("c","d")] :: IO String
?
On Mon, Dec 30, 2013 at 6:42 PM, Miro Karpis <miroslav.karpis at gmail.com> wrote:
> Hi, please can you help me with following?
>
> I have a following function:
> f1 :: (String, String) -> IO (Maybe String)
>
> which I would like to apply to a list of tuples.I have defined the function
> like this, but that gives me error (below):
>
> f2 :: [(String, String)] -> IO (Maybe String)
> f2 x = foldM f1 0 x
>
>
> error:
> Couldn't match expected type `IO (Maybe String)' with actual type `[b0] ->
> m0 (String, String)' In the return type of a call of `foldM'
>
> thanks,
> m.
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
More information about the Beginners
mailing list