[Haskell-cafe] Missing common function for Maybe types

Vanessa McHale vanessa.mchale at iohk.io
Tue Jul 31 11:39:16 UTC 2018


That doesn't exactly make sense. You'd need two versions of that
function in all likelihood - one left-biased and another right-biased.


On 07/31/2018 02:07 AM, Marc Busqué wrote:
> Hi!
>
> 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é
> http://waiting-for-dev.github.io/about/
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.

-- 



*Vanessa McHale*
Functional Compiler Engineer | Chicago, IL

Website: www.iohk.io <http://iohk.io>
Twitter: @vamchale
PGP Key ID: 4209B7B5

Input Output <http://iohk.io>

Twitter <https://twitter.com/InputOutputHK> Github
<https://github.com/input-output-hk> LinkedIn
<https://www.linkedin.com/company/input-output-global>


This e-mail and any file transmitted with it are confidential and
intended solely for the use of the recipient(s) to whom it is addressed.
Dissemination, distribution, and/or copying of the transmission by
anyone other than the intended recipient(s) is prohibited. If you have
received this transmission in error please notify IOHK immediately and
delete it from your system. E-mail transmissions cannot be guaranteed to
be secure or error free. We do not accept liability for any loss,
damage, or error arising from this transmission
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180731/b298afda/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180731/b298afda/attachment-0001.sig>


More information about the Haskell-Cafe mailing list