[Haskell-cafe] Maybe to Either -- is there a better way?
Christopher Done
chrisdone at googlemail.com
Wed Aug 4 13:53:38 EDT 2010
On 4 August 2010 18:40, Alexander Dunlap <alexander.dunlap at gmail.com> wrote:
> It's also nice for people reading code if common functions are
> functions from common libraries. This allows readers' "vocabulary" of
> common functions to increase, so they don't have to trawl through
> someone's personal "utility" library to figure out what each utility
> function does.
>
Agreed. That's why I like readMay. There are many ways to write a reads wrapper:
case reads str of [(x,_)] -> Just x; _ -> Nothing
vs
case reads str of [(x,"")] -> Just x; _ -> Nothing -- stricter
Etc. It seems everyone defines their one, where as Safe.readMay is
common. There could be others defined in Safe that encompass most
cases.
More information about the Haskell-Cafe
mailing list