raft-0.3.11.0: src/Data/Maybe/Util.hs
-----------------------------------------------------------------------------
--
-- Module : Data.Maybe.Util
-- Copyright : (c) 2014-16 Brian W Bush
-- License : MIT
--
-- Maintainer : Brian W Bush <consult@brianwbush.info>
-- Stability : Stable
-- Portability : Portable
--
-- | Utility functions for 'Data.Maybe'.
--
-----------------------------------------------------------------------------
{-# LANGUAGE Safe #-}
module Data.Maybe.Util (
-- * Utilities
maybeRead
) where
import Data.Maybe (listToMaybe)
-- | Maybe read a value.
maybeRead :: Read a
=> String -- ^ The string.
-> Maybe a -- ^ The value, if it could be parsed.
maybeRead = fmap fst . listToMaybe . reads