Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  foldM with tuple and maybe (Miro Karpis)
   2. Re:  foldM with tuple and maybe (David McBride)


----------------------------------------------------------------------

Message: 1
Date: Tue, 31 Dec 2013 00:42:26 +0100
From: Miro Karpis <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] foldM with tuple and maybe
Message-ID:
        <cajnnbxhffjm+oedbtoq0gxb7oxzfr+gpupfng7reteupgbp...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20131231/a9a5ec23/attachment-0001.html>

------------------------------

Message: 2
Date: Mon, 30 Dec 2013 19:01:44 -0500
From: David McBride <[email protected]>
To: Miro Karpis <[email protected]>,  The Haskell-Beginners
        Mailing List - Discussion of primarily beginner-level topics related
        to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] foldM with tuple and maybe
Message-ID:
        <CAN+Tr41SFEmcbwRSeatPuNyvZ0k-Z=bto_6mnru8khtj_-o...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

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 <[email protected]> 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
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>


------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 66, Issue 22
*****************************************

Reply via email to