HORIZON HASKELLDocslts/ghc-10.0.xaa25b892026-10-10Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · aa25b89 · 2026-10-10

Moduleutility-ht-0.0.17.2Haskell98

Data.Maybe.HT

  • 3 values
Example1 expression
import Control.Monad (guard)
valuetoMaybe :: Bool -> a -> Maybe a
#

Returns Just if the precondition is fulfilled. prop> b x -> (guard b >> x) == (toMaybe b =<< (x::Maybe Char))

value(?->) :: Maybe a -> (a -> b) -> Maybe b
#

This is an infix version of fmap for writing select style expressions using test functions, that produce Maybes.

The precedence is chosen to be higher than (:), in order to allow:

alternatives default $
   checkForA ?-> (\a -> f a) :
   checkForB ?-> (\b -> g b) :
   []

The operation is left associative in order to allow to write

checkForA ?-> f ?-> g

which is equivalent to

checkForA ?-> g . f

due to the functor law.