[Haskell-cafe] (no subject)
David Feuer
david.feuer at gmail.com
Tue Aug 16 23:04:49 UTC 2016
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.
On Aug 16, 2016 5:56 PM, "Corentin Dupont" <corentin.dupont at gmail.com>
wrote:
> That, right, just to clarify, my instances are like that:
>
> instance Applicative (Todo a) where
> pure = Done
> Todo as <*> Todo bs = Todo $ as ++ bs
> Todo as <*> _ = Todo as
> Done f <*> r = fmap f r
>
> instance Monad (Todo a) where
> return = Done
> Todo as >>= _ = Todo as
> Done a >>= f = f a
>
>
> It's basically accumulating on the Todos. Either [a] b does not fit
> because it does not accumulate on the a's.
>
>
> On Tue, Aug 16, 2016 at 11:12 PM, David Kraeutmann <kane at kane.cx> wrote:
>
>> I went from the assumption that he just wants something like
>>
>> instance Monad (Todo a)
>>
>> and that implies that b is the type inside of the monad.
>>
>>
>> On 08/16/2016 08:23 PM, David Kraeutmann wrote:
>> > This looks functionally identical to type Todo a b = Either [a] b, and
>> Either has a Monad instance.
>> > On 8/16/2016 8:21 PM, Corentin Dupont wrote:
>> >> Hi guys,
>> >> is there some library with a Monad (+Applicative, Functor...) instance
>> of
>> >> the following type:
>> >>
>> >> data Todo a b = Todo [a] | Done b
>> >>
>> >> Thanks!
>> >> Corentin
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> 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.
>> >>
>> >
>> >
>> >
>> > _______________________________________________
>> > 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.
>>
>> _______________________________________________
>> 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.
>>
>
>
> _______________________________________________
> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160816/18682798/attachment.html>
More information about the Haskell-Cafe
mailing list