{- Copyright (c) 2011 Robert Henderson This source file is distributed under the terms of a BSD3-style license, which can be found in the file LICENSE at the root of this package. -} -- | Extends "Data.Maybe" -- module Data.Maybe.Rosso1 (module Data.Maybe ,toMaybe ) where ------------------------------------------------------ import Data.Maybe -- | Dual of 'fromMaybe'. Wraps the value in 'Just' if the predicate -- succeeds, otherwise returns 'Nothing'. -- toMaybe :: (a -> Bool) -> a -> Maybe a toMaybe f x | f x = Just x | otherwise = Nothing ------------------------------------------------------ {- UNIT TESTS *Rosso.Maybe1> toMaybe (> 0) 1 Just 1 *Rosso.Maybe1> toMaybe (> 0) 0 Nothing -}