HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduleutility-ht-0.0.17.2Haskell98

Data.Maybe.HT

Synopsis
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.