[Haskell-cafe] Missing common function for Maybe types
david.feuer at gmail.com
Tue Jul 31 07:11:36 UTC 2018
Your code doesn't type check and there is no way to write a total function
with the type of foobar. What are you actually trying to do? Why do you say
this is "common"?
On Tue, Jul 31, 2018, 3:07 AM Marc Busqué <marc at lamarciana.com> wrote:
> I have two functions:
> foo :: a -> Maybe b
> bar :: a -> Maybe c
> From which I want to build a higher order function:
> foobar :: a -> (a -> Maybe b) -> (a -> Maybe c) -> Either b c
> The implementation I need is:
> foobar x f g =
> case (f x) of
> Nothing -> g x
> Just y -> Just y
> I'm a bit surprised that looking at hoogle I don't find a built-in
> solution for this quite common need for `Maybe` types (or perhaps for
> any monad).
> Am I looking in the wrong way? Does it exist a similar abstraction but
> with a different shape?
> Thanks in advance,
> Marc Busqué
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe