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: Simple function comparison (Stephen Renehan) 2. Re: Simple function comparison (MJ Williams) 3. Re: Simple function comparison (Francesco Ariis) 4. Re: Simple function comparison (Stephen Renehan) 5. Re: Simple function comparison (emacstheviking) 6. Re: is Haskell practical? (Martin Vlk) 7. Re: is Haskell practical? (KC) ---------------------------------------------------------------------- Message: 1 Date: Wed, 25 Nov 2015 14:32:07 +0000 From: Stephen Renehan <d11124...@mydit.ie> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Simple function comparison Message-ID: <CACoC9hDdE54XzNY6TiFmjsBxqFg5D8cesUaq81r5kN=3vd4...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Many thanks Franceso, I had thought as much as I was dealing with them only abstractly. Appreciate the quick reply and thanks for the help. On 25 November 2015 at 14:20, Francesco Ariis <fa...@ariis.it> wrote: > On Wed, Nov 25, 2015 at 11:39:15AM +0000, Stephen Renehan wrote: >> Hi, >> >> I'm looking to do a comparison between 2 simple functions to see if >> they are equivalent but I appear to be running into some problems if >> anyone can help. >> >> The two functions I want to compare are f (g a) and g (f a). >> >> I have f defined and g defined as >> f :: a -> a >> f = undefined >> >> g :: a -> a. >> g = undefined >> >> The compiler was complaining about the type signature lacking a >> binding so added undefined to get around the error. I understand that >> I must be missing something very basic as they look incomparable in >> this form. Any suggestions of what changes I should make such a >> comparison practical? > > Hello Stephen, > I don't think there is a way to /prove/ f (g a) == g (f a) if their > domain is not finite inside Haskell (you could do it with pen and > paper). > > If you have two functions and a finite domain you can do, say: > > -- function function domain > compfun :: (Eq a) => (a -> a) -> (a -> a) -> [a] -> Bool > compfun f g d = and $ map (\x -> (f . g) x == (g . f) x) d > > ?> compfun (+1) (+17) [1..10] > True > ?> compfun (*5) (+17) [1..10] > False > > Of course this is a toy example, use a proper library (quickcheck, etc.) > if you are writing a real program. > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -- This email originated from DIT. If you received this email in error, please delete it from your system. Please note that if you are not the named addressee, disclosing, copying, distributing or taking any action based on the contents of this email or attachments is prohibited. www.dit.ie Is ? ITB?C a th?inig an r?omhphost seo. M? fuair t? an r?omhphost seo tr? earr?id, scrios de do ch?ras ? le do thoil. Tabhair ar aird, mura t? an seola? ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon ch?ipe?il, aon d?ileadh n? ar aon ghn?omh a dh?anfar bunaithe ar an ?bhar at? sa r?omhphost n? sna hiat?in seo. www.dit.ie T? ITB?C ag aistri? go Gr?inseach Ghorm?in ? DIT is on the move to Grangegorman <http://www.dit.ie/grangegorman> ------------------------------ Message: 2 Date: Wed, 25 Nov 2015 15:48:08 +0000 From: MJ Williams <matthewjwilliams...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Simple function comparison Message-ID: <5655d836.07b71c0a.5d6b.6...@mx.google.com> Content-Type: text/plain; charset="us-ascii"; format=flowed [snip] >I don't think there is a way to /prove/ f (g a) == g (f a) if their >domain is not finite inside Haskell (you could do it with pen and paper). [snip] Just out of interest, could you demonstrate the proof without a finite domain? Sincerely, Matthew ------------------------------ Message: 3 Date: Wed, 25 Nov 2015 17:22:50 +0100 From: Francesco Ariis <fa...@ariis.it> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Simple function comparison Message-ID: <20151125162027.ga5...@casa.casa> Content-Type: text/plain; charset=us-ascii On Wed, Nov 25, 2015 at 03:48:08PM +0000, MJ Williams wrote: > [snip] > > >I don't think there is a way to /prove/ f (g a) == g (f a) if their domain > >is not finite inside Haskell (you could do it with pen and paper). > [snip] > Just out of interest, could you demonstrate the proof without a > finite domain? > > Sincerely, Matthew Say we have: f(x) = x + 1 g(x) = x + 7 Then we can substitute: f(g(x)) f(x+7) (x+7) + 1 x+8 and g(f(x)) g(x+1) (x+1) + 7 x+8 which shows f(g(x)) = g(f(x)) For anything more, my lawyer suggested I say: I have discovered a truly marvellous proof for it, but the margin of this email is to narrow to contain it. :P ------------------------------ Message: 4 Date: Wed, 25 Nov 2015 16:35:04 +0000 From: Stephen Renehan <d11124...@mydit.ie> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Simple function comparison Message-ID: <cacoc9hdwjpsqfxw45mwf-0jdrxgbmabnvt9yqacvxbc9tpw...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Hi Matthew, Was just about to reply that I only have the process written in long hand from the video that I enclose but I see Francesco beat me to it with a more concise explanation. Thanks again Francesco :) https://www.youtube.com/watch?v=ZhuHCtR3xq8 On 25 November 2015 at 15:48, MJ Williams <matthewjwilliams...@gmail.com> wrote: > [snip] > >> I don't think there is a way to /prove/ f (g a) == g (f a) if their domain >> is not finite inside Haskell (you could do it with pen and paper). > > [snip] > Just out of interest, could you demonstrate the proof without a > finite domain? > > Sincerely, Matthew > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -- This email originated from DIT. If you received this email in error, please delete it from your system. Please note that if you are not the named addressee, disclosing, copying, distributing or taking any action based on the contents of this email or attachments is prohibited. www.dit.ie Is ? ITB?C a th?inig an r?omhphost seo. M? fuair t? an r?omhphost seo tr? earr?id, scrios de do ch?ras ? le do thoil. Tabhair ar aird, mura t? an seola? ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon ch?ipe?il, aon d?ileadh n? ar aon ghn?omh a dh?anfar bunaithe ar an ?bhar at? sa r?omhphost n? sna hiat?in seo. www.dit.ie T? ITB?C ag aistri? go Gr?inseach Ghorm?in ? DIT is on the move to Grangegorman <http://www.dit.ie/grangegorman> ------------------------------ Message: 5 Date: Wed, 25 Nov 2015 16:54:53 +0000 From: emacstheviking <obji...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Simple function comparison Message-ID: <CAEiEuULiVVmUiyRz1DPq4DWDng-K=xqay1+clf3zfkqgq+f...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Awesome video, I watched it about ten times in a row and so many pennies dropped. On 25 November 2015 at 16:35, Stephen Renehan <d11124...@mydit.ie> wrote: > Hi Matthew, > > Was just about to reply that I only have the process written in long > hand from the video that I enclose but I see Francesco beat me to it > with a more concise explanation. Thanks again Francesco :) > > https://www.youtube.com/watch?v=ZhuHCtR3xq8 > > > On 25 November 2015 at 15:48, MJ Williams <matthewjwilliams...@gmail.com> > wrote: > > [snip] > > > >> I don't think there is a way to /prove/ f (g a) == g (f a) if their > domain > >> is not finite inside Haskell (you could do it with pen and paper). > > > > [snip] > > Just out of interest, could you demonstrate the proof without a > > finite domain? > > > > Sincerely, Matthew > > > > > > _______________________________________________ > > Beginners mailing list > > Beginners@haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -- > > > This email originated from DIT. If you received this email in error, please > delete it from your system. Please note that if you are not the named > addressee, disclosing, copying, distributing or taking any action based on > the contents of this email or attachments is prohibited. www.dit.ie > > Is ? ITB?C a th?inig an r?omhphost seo. M? fuair t? an r?omhphost seo tr? > earr?id, scrios de do ch?ras ? le do thoil. Tabhair ar aird, mura t? an > seola? ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon ch?ipe?il, aon > d?ileadh n? ar aon ghn?omh a dh?anfar bunaithe ar an ?bhar at? sa > r?omhphost n? sna hiat?in seo. www.dit.ie > > T? ITB?C ag aistri? go Gr?inseach Ghorm?in ? DIT is on the move to > Grangegorman <http://www.dit.ie/grangegorman> > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151125/5c510b24/attachment-0001.html> ------------------------------ Message: 6 Date: Wed, 25 Nov 2015 17:50:07 +0000 From: Martin Vlk <mar...@vlkk.cz> To: beginners@haskell.org Subject: Re: [Haskell-beginners] is Haskell practical? Message-ID: <5655f4cf.9000...@vlkk.cz> Content-Type: text/plain; charset=windows-1252 Dennis Raddle: > On Wed, Nov 25, 2015 at 4:56 AM, Alexander Berntsen <alexan...@plaimi.net> > wrote: <snip> > I don't agree. Having worked for 16 years in a government aerospace > contractor doing C++ and Python programming, what I saw is that maybe half > the programmers struggled with precise thinking and abstraction. They > thought of programs as step-by-step recipes and implemented those recipes > in exactly the same way they themselves had always thought about a problem. > > Also having worked as a math tutor, I see many people who struggle with > abstract thinking. <snip> > Can an "okay" imperative programmer become an "okay" Haskell programmer? > Does the necessary skill, work, motivation, and talent to program at an > "ordinary" imperative level serve as a sufficient prerequisite for > functional programming? I really don't think so, but I could be wrong. What'd be the definition of an okay programmer? If we agree that's the one that "learns how to solve a few standard problems and then applies the same thing over and over without much creativity", then I'll argue this will work with Haskell just like with any imperative language. If you train them on Haskell that is. :-) <snip> > But I wonder if the same mechanisms that make Haskell concise (which are > some of the things that make it hard) also are bound up with its practical > advantages so that they can't be separated. What you mean by practical? Does it mean that you can find enough people able to use it in your real-world project, without putting too high requirements on training them? If so, then we could say that given the current state of affairs, where the mass of okay programmers are trained on a different paradigm, Haskell is not all that practical. But if practical means that the language is well suited for solving real-world problems, in beautiful ways, once you get it, then it is uberpractical! :-) M. ------------------------------ Message: 7 Date: Wed, 25 Nov 2015 10:13:35 -0800 From: KC <kc1...@gmail.com> To: Haskell Beginners <beginners@haskell.org> Subject: Re: [Haskell-beginners] is Haskell practical? Message-ID: <CAMLKXy=ta8s-hngs6ocx495ekrqd_quuxpggukv5gnkvq9s...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Yes Haskell is practical except for finding Haskell replacement programmers. -- -- Sent from an expensive device which will be obsolete in a few months! :D Casey On Nov 25, 2015 9:50 AM, "Martin Vlk" <mar...@vlkk.cz> wrote: > > > Dennis Raddle: > > On Wed, Nov 25, 2015 at 4:56 AM, Alexander Berntsen < > alexan...@plaimi.net> > > wrote: > > <snip> > > > I don't agree. Having worked for 16 years in a government aerospace > > contractor doing C++ and Python programming, what I saw is that maybe > half > > the programmers struggled with precise thinking and abstraction. They > > thought of programs as step-by-step recipes and implemented those recipes > > in exactly the same way they themselves had always thought about a > problem. > > > > Also having worked as a math tutor, I see many people who struggle with > > abstract thinking. > > <snip> > > > Can an "okay" imperative programmer become an "okay" Haskell programmer? > > Does the necessary skill, work, motivation, and talent to program at an > > "ordinary" imperative level serve as a sufficient prerequisite for > > functional programming? I really don't think so, but I could be wrong. > > What'd be the definition of an okay programmer? If we agree that's the > one that "learns how to solve a few standard problems and then applies > the same thing over and over without much creativity", then I'll argue > this will work with Haskell just like with any imperative language. If > you train them on Haskell that is. :-) > > <snip> > > > But I wonder if the same mechanisms that make Haskell concise (which are > > some of the things that make it hard) also are bound up with its > practical > > advantages so that they can't be separated. > > What you mean by practical? Does it mean that you can find enough people > able to use it in your real-world project, without putting too high > requirements on training them? > > If so, then we could say that given the current state of affairs, where > the mass of okay programmers are trained on a different paradigm, > Haskell is not all that practical. > > But if practical means that the language is well suited for solving > real-world problems, in beautiful ways, once you get it, then it is > uberpractical! :-) > > M. > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151125/2cf10938/attachment.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 89, Issue 44 *****************************************