Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

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 <fa...@ariis.it>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] LYAH example
Message-ID: <20170322123033.ga3...@casa.casa>
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 <brutalles...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] LYAH example
Message-ID: <ef83c8d4-ec57-437c-9fbe-02bbad9a4...@gmail.com>
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 <fa...@ariis.it> 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
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners



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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


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

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

Reply via email to