On Sat, May 8, 2010 at 3:26 AM, John Meacham <john@repetae.net> wrote:
What counts as unfailable?
(x,y) probably, but what about
data Foo = Foo x y
If we don't allow it, we add 'magic' to tuples, which is a bad thing, if we do allow it, there are some odd consequences.
adding another constructor to Foo will suddenly change the type of do notations involving it non locally. said constructor may not even be exported from the module defining Foo, its existence being an implementation detail.
All in all, it is very hacky one way or another. Much more so than having 'fail' in Monad.
This is an interesting point, but I still disagree. A data type having constructors added or changed *is* going to break code in clients using it, or at least make GHC spit out a bunch of non-exhaustive warnings. It's then a good idea, I think, that people are forced to re-examine their use sites which don't obviously handle the new failing case. Presumably if they were really really sure then just a few well-placed ~s would make the problem go away. (i.e. to answer your question, pattern matching against any single-constructor data type should be unfailable in my opinion). On Sat, May 8, 2010 at 7:16 AM, Ivan Lazar Miljenovic <ivan.miljenovic@gmail.com> wrote:
As I said in another email: does not the "x <- Nothing" itself call fail as it expects x to be an actual value wrapped in Just?
No, the propagation of Nothings is done solely by the definition of
= for Monad, and doesn't need fail at all.