<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-15">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Something like "maybe" function?<br>
</p>
<br>
<div class="moz-cite-prefix">31.07.2018 10:07, Marc Busqué wrotes:<br>
</div>
<blockquote type="cite"
cite="mid:alpine.LNX.2.21.1807310857500.2536@localhost">Hi!
<br>
<br>
I have two functions:
<br>
<br>
```
<br>
foo :: a -> Maybe b
<br>
bar :: a -> Maybe c
<br>
```
<br>
<br>
From which I want to build a higher order function:
<br>
<br>
```
<br>
foobar :: a -> (a -> Maybe b) -> (a -> Maybe c) ->
Either b c
<br>
```
<br>
<br>
The implementation I need is:
<br>
<br>
```
<br>
foobar x f g =
<br>
case (f x) of
<br>
Nothing -> g x
<br>
Just y -> Just y
<br>
```
<br>
<br>
I'm a bit surprised that looking at hoogle I don't find a built-in
<br>
solution for this quite common need for `Maybe` types (or perhaps
for
<br>
any monad).
<br>
<br>
Am I looking in the wrong way? Does it exist a similar abstraction
but
<br>
with a different shape?
<br>
<br>
Thanks in advance,
<br>
<br>
Marc Busqué
<br>
<a class="moz-txt-link-freetext" href="http://waiting-for-dev.github.io/about/">http://waiting-for-dev.github.io/about/</a><br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
</blockquote>
<br>
</body>
</html>