aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Data/Maybe/Read.hs
blob: bc256d185df211ed4e8937f6456c905f00143e2e (plain)
1
2
3
4
5
6
7
8
module Data.Maybe.Read (readMaybe) where

-- readMaybe function from "Learn You a Haskell".  Used here under CC BY-NC-SA 3.0.

readMaybe    :: (Read a) => String -> Maybe a
readMaybe st = case reads st of
    [(x,"")] -> Just x
    _        -> Nothing