[Haskell-beginners] mayBe stuck
Brent Yorgey
byorgey at seas.upenn.edu
Fri Aug 6 08:38:56 EDT 2010
On Fri, Aug 06, 2010 at 11:15:52AM +0100, Colin Paul Adams wrote:
> >>>>> "Brent" == Brent Yorgey <byorgey at seas.upenn.edu> writes:
>
> >> Since Haskell allows programming with partial functions, you
> >> always have this burden at present.
>
> Brent> Yes. But that doesn't mean there isn't value in the
> Brent> discipline of avoiding them. The burden of making sure you
> Brent> never use fromJust (or head, or ...) is much lighter than the
> Brent> burden of proving that every such use is safe.
>
> The burden is knowing whether or not a function is partial. It's that or
> ... that is the problem. This isn't flagged anywhere.
That's a very good point. But it's the sort of thing you pick up
pretty quickly, I think. Here are some off the top of my head, for
beginners reading this who might not already know:
fromJust
head
tail
init
last
(!!)
For a fuller list, take a look at the 'safe' package on Hackage [1],
which also provides many different safe alternatives.
-Brent
[1] http://hackage.haskell.org/package/safe
More information about the Beginners
mailing list