8 Feb
2008
8 Feb
'08
5:17 a.m.
On Feb 7, 2008 6:12 PM, Ross Paterson <ross@soi.city.ac.uk> wrote:
I think this is a good idea, though I normally write the equivalent of
maybeRead :: Read a => String -> Maybe a maybeRead s = case reads s of [(x, rest)] | all isSpace rest -> Just x _ -> Nothing
and would prefer not to generalize it to any monad. fail is a wart, not a design pattern.
I also prefer Maybe to fail. Error strings are only useful if you're ignoring them or passing them to the user without interpretation. -- Dave Menendez <dave@zednenem.com> <http://www.eyrie.org/~zednenem/>