, . , .
, - , , . Nothing (, , ), , , .
, , , . , ReaderT. find, , both, , , oneOf, , , t . :
import Control.Monad
import Control.Monad.Reader
find a = ReaderT (lookup a)
both a b = liftM2 (++) a b
oneOf = mplus
search = both (find 1) ((find 2) `oneOf` (find 3))
`oneOf` both (find 4) (find 5)
:
(runReaderT search) [(1,"a"),(3,"c"),(4,"d"),(5,"g")] --> Just "ac"
(runReaderT search) [(6,"a")] --> Nothing
, , , . , , search_a search_b, , :
do a <- search_a
b <- search_b
return (merge a b)
, , liftM2 merge search_a search_b.