Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/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. Re:  LYAH example (Francesco Ariis)
   2. Re:  LYAH example (sasa bogicevic)


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

Message: 1
Date: Wed, 22 Mar 2017 13:30:33 +0100
From: Francesco Ariis <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] LYAH example
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Wed, Mar 22, 2017 at 12:44:23PM +0100, sasa bogicevic wrote:
> Hi All,
> Can someone clarify the example I got from LYAH book. This let statement
> is kinda confusing to me : 
> 
> applyLog :: (a, String) -> (a -> (b, String)) -> (b, String)
> applyLog (x, log) f = let (y, newLog) = f x in (y, log ++ newLog) 

Hello Sasa,
    let's rewrite `applyLog`:

    applyLog :: (a, String) -> (a -> (b, String)) -> (b, String)
    applyLog (x, log) f =
                              -- f      :: a -> (b, String)
        let (y, newLog) = f x -- y      :: b
                              -- newLog :: String
        in (y, log ++ newLog) -- (b, String)

f applied to x doesn't produce just `y`, but `y` and `newLog` (in
a Tuple). It is perfectly ok to specify a pattern:

    let (y, newLog) = f x -- legal

    let xyz = f x -- legal too. The first form saves you a `fst`/`snd`

Is it clearer now?


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

Message: 2
Date: Wed, 22 Mar 2017 14:29:05 +0100
From: sasa bogicevic <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] LYAH example
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Ahhhh I see, thank you very much for the response!

Have a nice day,
Sasa

{
        name: Bogicevic Sasa
        phone: +381606006200
}



> On Mar 22, 2017, at 13:30, Francesco Ariis <[email protected]> wrote:
> 
> On Wed, Mar 22, 2017 at 12:44:23PM +0100, sasa bogicevic wrote:
>> Hi All,
>> Can someone clarify the example I got from LYAH book. This let statement
>> is kinda confusing to me : 
>> 
>> applyLog :: (a, String) -> (a -> (b, String)) -> (b, String)
>> applyLog (x, log) f = let (y, newLog) = f x in (y, log ++ newLog) 
> 
> Hello Sasa,
>    let's rewrite `applyLog`:
> 
>    applyLog :: (a, String) -> (a -> (b, String)) -> (b, String)
>    applyLog (x, log) f =
>                              -- f      :: a -> (b, String)
>        let (y, newLog) = f x -- y      :: b
>                              -- newLog :: String
>        in (y, log ++ newLog) -- (b, String)
> 
> f applied to x doesn't produce just `y`, but `y` and `newLog` (in
> a Tuple). It is perfectly ok to specify a pattern:
> 
>    let (y, newLog) = f x -- legal
> 
>    let xyz = f x -- legal too. The first form saves you a `fst`/`snd`
> 
> Is it clearer now?
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners



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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 105, Issue 9
*****************************************

Reply via email to