digestive-functors-0.8.4.2: src/Text/Digestive/Util.hs
--------------------------------------------------------------------------------
-- | Utilities for safe failable parsing
module Text.Digestive.Util
( readMaybe
) where
--------------------------------------------------------------------------------
import Data.Maybe (listToMaybe)
--------------------------------------------------------------------------------
-- | 'read' in the 'Maybe' monad.
readMaybe :: Read a => String -> Maybe a
readMaybe str = listToMaybe [x | (x, "") <- readsPrec 1 str]