<p dir="ltr">Hi Corentin,</p>
<p dir="ltr">That's called the "Validation applicative". I'm on my phone so I can't link, but that phrase should give you a starting point. </p>
<p dir="ltr">Note that your type actually has no valid Monad instance that is consistent with the Applicative. That's because while the Applicative accumulates data, the Monad throws it away every time.</p>
<p dir="ltr">Chris</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Aug 17, 2016 09:56, "Corentin Dupont" <<a href="mailto:corentin.dupont@gmail.com">corentin.dupont@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>That, right, just to clarify, my instances are like that:<br><br><span style="font-family:monospace,monospace">instance Applicative (Todo a) where<br> pure = Done<br> Todo as <*> Todo bs = Todo $ as ++ bs<br> Todo as <*> _ = Todo as<br> Done f <*> r = fmap f r<br><br>instance Monad (Todo a) where<br> return = Done<br> Todo as >>= _ = Todo as<br> Done a >>= f = f a <br><br></span><span style="font-family:arial,helvetica,sans-serif"><br></span></div><span style="font-family:arial,helvetica,sans-serif">It's basically accumulating on the Todos. Either [a] b does not fit because it does not accumulate on the a's.<br></span><span style="font-family:monospace,monospace"><br></span><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 16, 2016 at 11:12 PM, David Kraeutmann <span dir="ltr"><<a href="mailto:kane@kane.cx" target="_blank">kane@kane.cx</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I went from the assumption that he just wants something like<br>
<br>
instance Monad (Todo a)<br>
<br>
and that implies that b is the type inside of the monad.<br>
<div><div><br>
<br>
On 08/16/2016 08:23 PM, David Kraeutmann wrote:<br>
> This looks functionally identical to type Todo a b = Either [a] b, and Either has a Monad instance.<br>
> On 8/16/2016 8:21 PM, Corentin Dupont wrote:<br>
>> Hi guys,<br>
>> is there some library with a Monad (+Applicative, Functor...) instance of<br>
>> the following type:<br>
>><br>
>> data Todo a b = Todo [a] | Done b<br>
>><br>
>> Thanks!<br>
>> Corentin<br>
>><br>
>><br>
>><br>
>> ______________________________<wbr>_________________<br>
>> Haskell-Cafe mailing list<br>
>> To (un)subscribe, modify options or view archives go to:<br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
>> Only members subscribed via the mailman list are allowed to post.<br>
>><br>
><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> Haskell-Cafe mailing list<br>
> To (un)subscribe, modify options or view archives go to:<br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
> Only members subscribed via the mailman list are allowed to post.<br>
<br>
______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.</div></div></blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div></div>