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. Re: Question on evaluating function compostion (Erik Price)
2. Detecting duplicate code by AST? (Frank)
3. Re: understanding curried function calls (Brent Yorgey)
4. Re: Detecting duplicate code by AST? (Ozgur Akgun)
5. Re: understanding curried function calls (Gesh)
----------------------------------------------------------------------
Message: 1
Date: Thu, 21 Aug 2014 10:37:38 -0400
From: Erik Price <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question on evaluating function
compostion
Message-ID:
<CAD+X7c-xWtr4-+=V1ckdf8pHGwe+Lg5H06FsOZ=tos9aghs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
>
> Why did Haskell, however, not try to fully evaluate addition,
> like following?
> (liftM . (+)) 1 [2] --->
> liftM ((+) 1 [2]) --->
> error
>
Haskell functions only consume one argument, not two. The composed function
is applied to the first argument, which is 1. That returns a new function,
which is applied to the next argument, which is [2].
e
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140821/88f2cf53/attachment-0001.html>
------------------------------
Message: 2
Date: Thu, 21 Aug 2014 11:27:25 -0400
From: Frank <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Detecting duplicate code by AST?
Message-ID:
<CA+a3wkKKfk6jjfN9P7aPxX_E++rhde=afmud2+kmp5fcus8...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi,
Can Anyone point Me in the direction of a tool/method of detecting code
duplicates based on analysis of abstract syntax trees (ASTs)? If not, is
there a way to dump the ASTs of a Haskell project? Is this something
for Template Haskell to handle?
Sincerely,
Frank D. Martinez
--
P.S.: I prefer to be reached on BitMessage at
BM-2D8txNiU7b84d2tgqvJQdgBog6A69oDAx6
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140821/70c0c17c/attachment-0001.html>
------------------------------
Message: 3
Date: Thu, 21 Aug 2014 12:43:28 -0400
From: Brent Yorgey <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] understanding curried function calls
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Hi Dimitri,
Yes, this is one possible systematic approach, which will always work.
And it's the one I happen to prefer. (Another approach is to turn
everything into lambdas, as pointed out earlier in this thread, but
that is noisier and does not correspond to the usual Haskelly way of
defining functions.) I am not sure exactly what you are trying to do
with the foldl/foldr example, but you should be able to use this
same approach to evaluate it.
-Brent
On Wed, Aug 20, 2014 at 03:11:22PM -0600, Dimitri DeFigueiredo wrote:
> Hi Brent,
>
> Is this how we go about solving these then?
> Keep adding parameters on the right until we have enough of them that
> we are able to apply the function definition.
>
> In other words, in
> ex1 = doTwice doTwice
>
> the first doTwice needs another parameter, so you added 'y'.
> ex1 y = (doTwice doTwice) y = doTwice doTwice y
>
> Then we can apply the definition.
> We got stuck again, so you added another parameter 'z'.
> Then again applied the definition of the left most function.
> And so on.
>
> Is there a similarly systematic approach for the foldl implemented by
> foldr example?
> I'm looking for systematic approaches that I can then practice.
>
>
> Thanks!
>
>
> Dimitri
>
>
> Em 20/08/14 14:30, Brent Yorgey escreveu:
> >On Wed, Aug 20, 2014 at 02:19:16AM -0600, Dimitri DeFigueiredo wrote:
> >>doTwice :: (a -> a) -> a -> a
> >>doTwice f x = f (f x)
> >>
> >>what does this do?
> >>
> >>ex1 :: (a -> a) -> a -> a
> >>ex1 = doTwice doTwice
> >>
> >>At least, it is clear that there is a parameter to doTwice missing.
> >>So, I wanted to do:
> >>
> >>ex1 y = (doTwice doTwice) y
> >>
> >>but this gets me nowhere as I don't know how to apply the definition
> >>of doTwice inside
> >>the parenthesis without naming the arguments.
> >Note that function application associates to the left, so
> >
> > (doTwice doTwice) y = doTwice doTwice y
> >
> >So, we have
> >
> >ex1 y = doTwice doTwice y
> > = doTwice (doTwice y) -- definition of doTwice
> >
> >Now we are stuck again; we can add another arbitrary parameter.
> >
> >ex1 y z = doTwice (doTwice y) z
> > = (doTwice y) ((doTwice y) z)
> > = doTwice y (doTwice y z) -- remove unnecessary parentheses
> > = y (y (doTwice y z))
> > = y (y (y (y z)))
> >
> >Does that help?
> >
> >>What is the systematic way to evaluate these expressions? I actually
> >>got really
> >>stumped when I considered.
> >>
> >>ex2 :: (a -> a) -> a -> a
> >>ex2 = doTwice doTwice doTwice doTwice
> >>
> >>I assume this is not the same as
> >>
> >>ex2 = (doTwice doTwice doTwice) doTwice
> >These ARE exactly the same. It's always the case that
> >
> > f w x y z ... = (((f w) x) y) z ...
> >
> >-Brent
> >_______________________________________________
> >Beginners mailing list
> >[email protected]
> >http://www.haskell.org/mailman/listinfo/beginners
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
------------------------------
Message: 4
Date: Thu, 21 Aug 2014 18:55:46 +0200
From: Ozgur Akgun <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Detecting duplicate code by AST?
Message-ID:
<calzazpbz0hn5ycaawthx8-9knz_m0g683uc2zoae7hsjipk...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On 21 August 2014 17:27, Frank <[email protected]> wrote:
> Can Anyone point Me in the direction of a tool/method of detecting code
> duplicates based on analysis of abstract syntax trees (ASTs)?
>
hlint can do a form of this. give it a go.
cabal install hlint && hlint --help
hope this helps,
--
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140821/7275ea31/attachment-0001.html>
------------------------------
Message: 5
Date: Thu, 21 Aug 2014 20:44:10 +0300
From: Gesh <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] understanding curried function calls
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 8/21/2014 7:43 PM, Brent Yorgey wrote:
> [eta-expand everything as necessary]
You learn something new every day. Didn't think of this approach before,
thanks, Brent!
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 74, Issue 21
*****************************************