[Haskell-cafe] Safe way to parse arguments?

Xiao-Yong Jin xj2106 at columbia.edu
Sat Jun 21 15:46:57 EDT 2008


Don Stewart <dons at galois.com> writes:

> The main thing is to define a safe read. This will be in the base
> library soon,
>
>       maybeRead :: Read a => String -> Maybe a
>       maybeRead s = case reads s of
>           [(x, "")] -> Just x
>           _         -> Nothing
>
> Then you can pattern match on the failure case as Nothing.

When will it be in the base library?

X-Y
-- 
    c/*    __o/*
    <\     * (__
    */\      <


More information about the Haskell-Cafe mailing list