Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix readMaybe

  • Loading branch information...
commit 47676414b6cb08e0f5bc6128d52f40ae01618b44 1 parent ce987d0
@jaspervdj authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 digestive-functors/src/Text/Digestive/Util.hs
View
8 digestive-functors/src/Text/Digestive/Util.hs
@@ -5,8 +5,10 @@ module Text.Digestive.Util
--------------------------------------------------------------------------------
+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]
Please sign in to comment.
Something went wrong with that request. Please try again.