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 re "Pattern match(es) are non-exhaustive"
(Kim-Ee Yeoh)
2. Re: Question re "Pattern match(es) are non-exhaustive"
(Kim-Ee Yeoh)
3. Re: Question re "Pattern match(es) are non-exhaustive"
(Joel Neely)
4. Re: Question re "Pattern match(es) are non-exhaustive"
(Kim-Ee Yeoh)
5. Re: Fwd: GHC 7.10 Prelude: we need your opinion (Julian Birch)
----------------------------------------------------------------------
Message: 1
Date: Wed, 11 Feb 2015 00:01:41 +0700
From: Kim-Ee Yeoh <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question re "Pattern match(es) are
non-exhaustive"
Message-ID:
<capy+zdssygbviovyv4b1qgdko4j9c-7xd8pgo+q85czad-s...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Tue, Feb 10, 2015 at 11:14 PM, Frerich Raabe <[email protected]> wrote:
> Interesting! This got me thinking - is this issue because the compiler
> doesn't (cannot?) see the implementation of e.g. (<=)?
>
>
It "sees" the implementation of (<=) for otherwise it won't be able to
generate code for it. But see below.
> I noticed that a similiar case exists with
>
> f :: Bool -> Bool
> f x | x = True
> | not x = False
>
> ...which yields the same warning. I suppose this is because the compiler
> doesn't know the definition of 'not' so it doesn't understand that either
> of the two guards will always be True.
Again, it has to "know" the definition of the function "not" because it has
to generate code to call it.
But it doesn't "know" the function from any other function, say foo.
Semantically speaking, both are equally opaque.
Now you could point out that "Ah, but look at the definition of not. It
could inline, simplify, et voila, obtain
f True = True
f False = False
and hence pattern-matching is complete."
Therein lies the rub. All that inlining and simplification boils down to
evaluating the program _in_ the compiler, so if your program diverges so
would the compiler, which wouldn't be a happy thing.
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20150211/697b5bb9/attachment-0001.html>
------------------------------
Message: 2
Date: Wed, 11 Feb 2015 00:07:43 +0700
From: Kim-Ee Yeoh <[email protected]>
To: "[email protected]" <[email protected]>
Subject: Re: [Haskell-beginners] Question re "Pattern match(es) are
non-exhaustive"
Message-ID:
<CAPY+ZdQpr1Xoz3AKBoNVLVU3nNQfzy9ufJM0h_hQEO1Vx_Zp=g...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Wed, Feb 11, 2015 at 12:01 AM, Kim-Ee Yeoh <[email protected]> wrote:
> All that inlining and simplification boils down to evaluating the program
> _in_ the compiler
My apologies, I meant "amounts to", not "boils down to".
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20150211/0d99d6d4/attachment-0001.html>
------------------------------
Message: 3
Date: Tue, 10 Feb 2015 11:11:02 -0600
From: Joel Neely <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question re "Pattern match(es) are
non-exhaustive"
Message-ID:
<CAEEzXAguonFeZ9OPZej7YaJ7_xvNDkyMGEt=9yvloetodqa...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Thanks for all the good explanations! I was misdirected by the fact that
the warning location was on the empty case, but based on descriptions I
think I understand why now.
I find it interesting that there is a bit of a conflict between "good
practice" heuristics:
1. Use -Wall (to eliminate questionable code that triggers warnings), and
2. Avoid _ in patterns in favor of explicit statement of the cases.
So it would appear that the advice (per Kim-Ee) to add an "otherwise" as a
third guard allows me to satisfy the compiler while documenting to the
human reader that the definition is really complete without it.
Thanks,
-jn-
On Tue, Feb 10, 2015 at 9:52 AM, Kim-Ee Yeoh <[email protected]> wrote:
>
> On Tue, Feb 10, 2015 at 7:58 PM, Joel Neely <[email protected]> wrote:
>
>> sumDigits (n:ns)
>> | n < 10 = n + sumDigits ns
>> | n >= 10 = r + sumDigits (q : ns)
>> where (q, r) = n `quotRem` 10
>>
>
> To reiterate what Mike and Brandon just said, it's not that both the []
> and (n:ns) cases have not been covered. They have.
>
> It's that the (n:ns) case hasn't been covered completely because of the
> guards.
>
> This will work:
>
> sumDigits (n:ns)
> | n < 10 = n + sumDigits ns
> | otherwise = r + sumDigits (q : ns)
>
> As will this:
>
> sumDigits (n:ns)
> | n < 10 = n + sumDigits ns
> | n >= 10 = r + sumDigits (q : ns)
> | otherwise = error "will never fire, only to suppress spurious
> warning"
>
> There's also -fno-warn-incomplete-patterns.
>
> -- Kim-Ee
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
--
Beauty of style and harmony and grace and good rhythm depend on simplicity.
- Plato
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20150210/29ad73a2/attachment-0001.html>
------------------------------
Message: 4
Date: Wed, 11 Feb 2015 00:39:06 +0700
From: Kim-Ee Yeoh <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question re "Pattern match(es) are
non-exhaustive"
Message-ID:
<capy+zdqeskt7xuqvxxjbg93d0t_1bhsus3noh_dagwnns2h...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Wed, Feb 11, 2015 at 12:11 AM, Joel Neely <[email protected]> wrote:
> So it would appear that the advice (per Kim-Ee) to add an "otherwise" as a
> third guard allows me to satisfy the compiler while documenting to the
> human reader that the definition is really complete without it.
Thanks for the citation! But if you look at lots of haskell code, I don't
think there's One Best Style on how to write haskell. E.g. I hardly ever
use guards and I'm far from being alone. For the code in question I'd
probably have ended up with an if expression, although I do see the
structural elegance that guards bring here.
Another e.g. some will argue that the "right" approach is to collapse to 2
guards with the otherwise in the 2nd one. So the reader is expected to
infer in a snap that if n is not < 10 then obviously it's >= 10.
A "strong opinions, weakly held" strategy might work best. Be bold, make
choices, trust in the warm diversity of the haskell universe.
Don Stewart has a nice list of coding styles here:
http://stackoverflow.com/a/6399082
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20150211/b36ca6a9/attachment-0001.html>
------------------------------
Message: 5
Date: Tue, 10 Feb 2015 22:15:37 +0000
From: Julian Birch <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Fwd: GHC 7.10 Prelude: we need your
opinion
Message-ID:
<cab0tuzcrs0ez+8vnya6sio1crnu-xfxvxvxv9jcq81yexup...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Ironically, as a beginner, I supported FTP. As a beginner, I don't need to
worry about legacy compatibility, but I do worry about cognitive overload.
And actually, for someone coming from almost any other language, having a
non-general fold is a speedbump for me.
As for sequence in its full generality, I don't know if I completely grasp
it, but the basic idea of swapping two typeclasses around I found the first
time I hoogled for something that did exactly that.
J
On 10 February 2015 at 16:46, Kim-Ee Yeoh <[email protected]> wrote:
> Simon PJ missed out the haskell-beginners list, but I encourage you to
> fill out the survey below as well.
>
> Now you may ask, "Well, I'm still learning haskell and I don't know
> enough."
>
> But consider that by being on this list and by haskelling whatever you may
> consider as utterly insignificant, you're still waaaaaaaay ahead than those
> who have yet to reach haskell at all.
>
> Your opinion counts.
>
> Because those _after_ you will help provide jobs by creating haskell
> projects, just like you.
>
> But unlike them, you get to influence the haskell of tomorrow that will be
> their first encounter, whether that would be a haskell that's friendlier or
> more @#$%^& than what it is today.
>
> The survey link is here:
> *http://goo.gl/forms/XP1W2JdfpX <http://goo.gl/forms/XP1W2JdfpX>*
>
> Summaries (each quite long) are here:
>
> ? Overall summary:
> https://ghc.haskell.org/trac/ghc/wiki/Prelude710
> <https://www.google.com/url?q=https%3A%2F%2Fghc.haskell.org%2Ftrac%2Fghc%2Fwiki%2FPrelude710&sa=D&sntz=1&usg=AFQjCNE1p5w-YCXC7ixebvwObayuV7Ut4w>
>
> ? Details of Plan List:
> https://ghc.haskell.org/trac/ghc/wiki/Prelude710/List
> <https://www.google.com/url?q=https%3A%2F%2Fghc.haskell.org%2Ftrac%2Fghc%2Fwiki%2FPrelude710%2FList&sa=D&sntz=1&usg=AFQjCNHaufeSwtIsvZwdVXwP9F9G45zLSA>
> ? Details of Plan FTP:
> https://ghc.haskell.org/trac/ghc/wiki/Prelude710/FTP
> <https://www.google.com/url?q=https%3A%2F%2Fghc.haskell.org%2Ftrac%2Fghc%2Fwiki%2FPrelude710%2FFTP&sa=D&sntz=1&usg=AFQjCNHbhNyIwAbcOd3JfikIhD6S7rc-vw>
>
> Fwiw, I voted to delay FTP. In fact, here's what I wrote:
>
> "FTP is rushed and potentially unstable. I don't think we understand all
> about Traversable that we think we do, which might mean another big Prelude
> overhaul in the future.
>
> Actually, FTP doesn't even belong in 7.12 per se. It belongs in a new
> Haskell language standard and if that coincides with GHC 7.12, great. If
> not, it can wait for GHC 8.x and up."
>
> Because I've been keeping tabs on FTP I wrote my opinion without perusing
> the summaries, but on doing so later, I stumbled upon the following points
> that happen to reflect my exact observations, points that are relevant to
> learning haskell and growing the haskell community:
>
> https://ghc.haskell.org/trac/ghc/wiki/Prelude710/List
>
>
> - The existing corpus of books, tutorials, syllabi, and the like
> usually have a significant portion of the text dedicated to these very
> Prelude functions - and they would all need significant revision.
>
>
> - Teaching beginners what sequence means in its full generality is
> going to be a challenge.
>
>
> - While teaching beginners who end up on #haskell IRC might be
> possible, this is likely to increase the "bounce" rate, people who see
> Haskell, play around, and run away scared. I think Haskell probably has a
> higher bounce rate than most other languages, making it worse would be bad.
>
>
> Whether you agree or disagree with the above, now's the time to make
> yourself heard. The survey closes Feb 21.
>
> p.s. Needless to say, feel free to discuss FTP on this list should your
> opinion need a sounding board and a bit of time (not too long!) to firm up.
>
> -- Kim-Ee
>
> ---------- Forwarded message ----------
> From: Simon Peyton Jones <[email protected]>
> Date: Tue, Feb 10, 2015 at 10:50 PM
> Subject: GHC 7.10 Prelude: we need your opinion
> To: "[email protected]" <[email protected]>, "Haskell Cafe (
> [email protected])" <[email protected]>, GHC users <
> [email protected]>, "[email protected]" <
> [email protected]>
>
>
> Haskell Friends
>
> *This email asks for your help in deciding how to proceed with some
> Prelude changes in GHC 7.10. Please read on, but all the info is also at
> the survey link, here: http://goo.gl/forms/XP1W2JdfpX
> <http://goo.gl/forms/XP1W2JdfpX>. Deadline is 21 Feb.*
>
>
>
> The ?Core Libraries Committee (CLC) is responsible for developing the core
> libraries that ship with GHC. This is an important but painstaking task,
> and we owe the CLC a big vote of thanks for taking it on.
>
> For over a year the CLC has been working on integrating the *Foldable and
> Traversable classes* (shipped in base in GHC 7.8) into the core
> libraries, and into the Prelude in particular. Detailed planning for GHC
> 7.10 started in the autumn of 2014, and the CLC went ahead with this
> integration.
>
> Then we had a failure of communication. As these changes affect the
> Prelude, which is in scope for all users of Haskell, these changes should
> be held to a higher bar than the regular libraries@ review process.
> However, the Foldable/Traversable changes were not particularly well
> signposted. Many people have only recently woken up to them, and some have
> objected (both in principle and detail).
>
> This is an extremely unfortunate situation. On the one hand we are at RC2
> for GHC 7.10, so library authors have invested effort in updating their
> libraries to the new Prelude. On the other, altering the Prelude is in
> effect altering the language, something we take pretty seriously. We should
> have had this debate back in 2014, but here we are, and it is unproductive
> to argue about whose fault it is. We all share responsibility.
>
> We need to decide what to do now. A small group of us met by Skype and
> we've decided to do this:
>
> ? Push back GHC 7.10's release by at least a month, to late
> March. This delay also gives us breathing space to address an unrelated
> show-stopping bug, Trac #9858.
>
> ? Invite input from the Haskell community on which of two
> approaches to adopt (this survey <http://goo.gl/forms/XP1W2JdfpX>). The
> main questions revolve around impact on the Haskell ecosystem (commercial
> applications, teaching, libraries, etc etc), so we want to ask your opinion
> rather than guess it.
>
> ? Ask Simon Marlow and Simon Peyton Jones to decide which
> approach to follow for GHC 7.10.
>
> Wiki pages have been created summarizing these two primary alternatives,
> including many more points and counter-points and technical details:
>
> ? Overall summary:
> https://ghc.haskell.org/trac/ghc/wiki/Prelude710
> <https://www.google.com/url?q=https%3A%2F%2Fghc.haskell.org%2Ftrac%2Fghc%2Fwiki%2FPrelude710&sa=D&sntz=1&usg=AFQjCNE1p5w-YCXC7ixebvwObayuV7Ut4w>
>
> ? Details of Plan List:
> https://ghc.haskell.org/trac/ghc/wiki/Prelude710/List
> <https://www.google.com/url?q=https%3A%2F%2Fghc.haskell.org%2Ftrac%2Fghc%2Fwiki%2FPrelude710%2FList&sa=D&sntz=1&usg=AFQjCNHaufeSwtIsvZwdVXwP9F9G45zLSA>
>
> ? Details of Plan FTP:
> https://ghc.haskell.org/trac/ghc/wiki/Prelude710/FTP
> <https://www.google.com/url?q=https%3A%2F%2Fghc.haskell.org%2Ftrac%2Fghc%2Fwiki%2FPrelude710%2FFTP&sa=D&sntz=1&usg=AFQjCNHbhNyIwAbcOd3JfikIhD6S7rc-vw>
>
> This survey invites your input on which plan we should follow. Would you
> please
>
> ? Read the details of the alternative plans on the three wiki
> pages above
>
> ? Add your response to the survey <http://goo.gl/forms/XP1W2JdfpX>
>
> Please do read the background. Well-informed responses will help. Thank
> you!
>
> *DEADLINE: 21 February 2015*
>
> Simon PJ
>
> _______________________________________________
> ghc-devs mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/ghc-devs
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20150210/68bbad88/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 80, Issue 19
*****************************************