<p dir="ltr">Your Monad instance does not correspond to your Applicative instance as required by the class laws. Your Monad instance never appends the way the Applicative one does. And there's no way to make it do so. I don't think you've defined your type the way you really want. But without many details about how you wish to use it, it's hard to say how to fix the problem.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Aug 16, 2016 5:56 PM, "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>