Hi

IMHO I think that isJust/fromJust could simply be removed. Using
'maybe' is a much better practice, it is safe and much even more
expressive.

Yes, its more expressive if you let someone write (error "Umm, what
should I do here?") as one of the options. And now you've gone from
something with a clear precondition, to something that merely floats a
lazy _|_ value around the place. If you take that route be careful
with strictness annotations!


head on the other hand might be considered more necessary but right
now I cannot think of a situation in which it's use shows any
advantage over simple pattern matching.

You can map head over a list, a function is a first class citizen. To
make a pattern match into a first class item you need to turn it into
a case or a lambda. Either way you can't import/export pattern matches
from modules etc.

I like both fromJust and head, they have clearly defined meanings,
although obviously you have to be slightly careful about their use.
Fortunately the problem of pattern match errors is being tackled by at
least two projects:

* Catch: http://www-users.cs.york.ac.uk/~ndm/projects/catch.php
* ESC-Haskell: http://www.cl.cam.ac.uk/~nx200/research/escH-hw.ps

Neither has a practical released tool yet, but hopefully that will
have changed in a few months!

It's anyway worth to check Neil's Safe library
http://www-users.cs.york.ac.uk/~ndm/projects/safe/Safe.html

Despite the fact that I like head/fromJust etc, a safe list library
would be kind of handy. If someone wants to roll that into the Safe
library, as Safe.List or something, I'd be happy to accept patches
(saving someone else the hassle of setting up a new library etc, for
roughly the same purpose)

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to