Donald Bruce Stewart wrote:
> So how do we help out the beginners, other than warning about fromJust,
> and providing a useful error message as we can, for when they just go
> ahead and use head anyway?

Kill head and tail right now and provide a safe equivalent?  Either

  uncons :: [a] -> Maybe (a,[a])

which is to be used in conjunction with 'maybe' (or with
fmap/first/second/unfoldr) or

  list :: r -> (a -> [a] -> r) -> [a] -> r

in analogy with 'maybe' and 'either'.  Or combine it with 'foldr' to
form the paramorphism (if I got the terminology right).  Or even better,
don't mention the existence of uncons and encourage people to write list
consumers in terms of 'destroy'.


-Udo
-- 
Sturgeon's Law: Ninety percent of everything is crud.
(Sturgeon was an optimist.)

Attachment: signature.asc
Description: Digital signature

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

Reply via email to