tag:blogger.com,1999:blog-7094652.post3229993550611550249..comments2024-03-23T14:36:09.980+00:00Comments on Neil Mitchell's Blog (Haskell etc): The patternNeil Mitchellhttp://www.blogger.com/profile/13084722756124486154noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-7094652.post-65746982191379628802020-03-31T20:32:35.376+01:002020-03-31T20:32:35.376+01:00You also can't reveal existential variables wi...You also can't reveal existential variables with let, but you can with <- pure (since it's actually a case statement).Ganesh Sittampalamhttps://www.blogger.com/profile/16862546723726662511noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-33808584313915286362020-03-20T02:48:04.657+00:002020-03-20T02:48:04.657+00:00I agree that it would be nice to have a non-recurs...I agree that it would be nice to have a non-recursive let.<br /><br />Rather than ignoring all name-shadowing (as some represent bugs), it would be nice to have a way to indicate when you want a new binding to make the previous binding go out of scope. I don't have a proposal but it would be nice.Steven Shawhttps://www.blogger.com/profile/11062749001442886118noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-26799194174640781732020-03-19T20:12:02.801+00:002020-03-19T20:12:02.801+00:00Thanks for writing this up! I first heard about th...Thanks for writing this up! I first heard about this technique from a presentation which referenced https://mail.haskell.org/pipermail/haskell-cafe/2013-July/109116.html and it's much better to be able to link to a blog post.Vaibhavhttps://www.blogger.com/profile/08707215962723788074noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-12681166763426390112020-03-19T14:10:35.753+00:002020-03-19T14:10:35.753+00:00`-Wno-name-shadowing` is one of the first things I...`-Wno-name-shadowing` is one of the first things I add after `-Wall -Werror -Wextra`Noahhttps://www.blogger.com/profile/12638229035633367208noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-11773398510106497722020-03-16T20:16:50.144+00:002020-03-16T20:16:50.144+00:00Thanks for all the points, I've added a warnin...Thanks for all the points, I've added a warnings section to the bottom of the blog listing them.Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-64645028033313448832020-03-16T20:14:48.127+00:002020-03-16T20:14:48.127+00:00Justin: Good point!
Ben: I disable that GHC warni...Justin: Good point!<br /><br />Ben: I disable that GHC warning - I find it harmful rather than helpful, and indeed in the process of GHC itself becoming -Wall clean one of the changes introduced a bug much like described above.Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-16613591544801700212020-03-16T18:29:50.026+00:002020-03-16T18:29:50.026+00:00Unfortunately with -Wall ghc gives you a shadowing...Unfortunately with -Wall ghc gives you a shadowing warning for "x <- pure (x + 1)". The only solution I found is to use a name that starts with an underscore e.g. "_x".Ben Franksennoreply@blogger.comtag:blogger.com,1999:blog-7094652.post-83523478187302518732020-03-16T16:49:02.228+00:002020-03-16T16:49:02.228+00:00One main distinction between the two that might be...One main distinction between the two that might be worth noting is polymorphism. The let binding is allowed to stay polymorphic (and will actually be inferred as such, unless MonoLocalBinds is on). The version with <- will necessarily be monomorphic. This behavior can be useful in both ways, as the implicit monomorphization can help with sharing. Justinhttps://www.blogger.com/profile/06136840792496025317noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-51147073235188454022020-03-16T15:37:40.237+00:002020-03-16T15:37:40.237+00:00Re "The one place they aren't fully equiv...Re "The one place they aren't fully equivalent is when myExpression contains x within it", there's a second place too: if "x" is a refutable pattern and it doesn't match, the "let =" way will put bottoms in whatever variables were in the pattern, whereas the "<- pure" way will call "fail" instead.<br /><br />Also, it's worth noting that your technique will cause a compiler error if you use it within "mdo" or "rec" from the RecursiveDo extension.Joseph C. Siblehttps://www.blogger.com/profile/15544501235128035435noreply@blogger.com