Skip to content

Commit

Permalink
Fix readMaybe
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Oct 24, 2012
1 parent ce987d0 commit 4767641
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions digestive-functors/src/Text/Digestive/Util.hs
Expand Up @@ -4,9 +4,11 @@ module Text.Digestive.Util
) where


--------------------------------------------------------------------------------
import Data.Maybe (listToMaybe)


--------------------------------------------------------------------------------
-- | 'read' in the 'Maybe' monad.
readMaybe :: Read a => String -> Maybe a
readMaybe str = case readsPrec 1 str of
[(x, "")] -> Just x
_ -> Nothing
readMaybe str = listToMaybe [x | (x, "") <- readsPrec 1 str]

0 comments on commit 4767641

Please sign in to comment.