I'm going through some Haskell tutorials and trying to get familiar with the language. I've seen this example in a Monad/MonadPlus tutorial:
data Sheep = Sheep {name :: String, mother :: Maybe Sheep, father :: Maybe Sheep}
parent :: Sheep -> Maybe Sheep
parent s = mother s `mplus` father s
I was trying to rewrite it in point-free style (just as an exercise, not saying that the above is wrong or non-idiomatic), but I got stuck: obviously I can write a custom function
partialPlus :: (MonadPlus m) => (a -> m b) -> (a -> m b) -> a -> m b
partialPlus f1 f2 = \x -> f1 x `mplus` f2 x
and then use
parent = partialPlus mother father
but I seem to remember from the LYAH tutorial that there was a way to use functors or applicative functors to construct tree of computations that can be finally fed arguments to get the result out of the "functor-box". However I can't seem to find the example in the tutorial. How do I rewrite the above "cleverly"?