
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

On Tue, Aug 16, 2016 at 08:21:31PM +0200, 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
What is the general idea behind the "todo monad"? As an unrepented procrastinator, I might learn something useful.

You could say that yak shaving is bind, you just get more stuff on the
"todo list".
On Tue, Aug 16, 2016 at 2:21 PM, Francesco Ariis
On Tue, Aug 16, 2016 at 08:21:31PM +0200, 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
What is the general idea behind the "todo monad"? As an unrepented procrastinator, I might learn something useful. _______________________________________________ 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.
-- Mihai Maruseac (MM) "If you can't solve a problem, then there's an easier problem you can solve: find it." -- George Polya

Honest question -- why use this over e.g. a callback function?
The point of this structure, as I understand it, would be to establish the
status of asynchronous computations being performed from `[a]`; it follows
that this status would be used to execute a follow-up computation.
Jules
On Aug 16 2016, at 2:27 pm, Francesco Ariis
On Tue, Aug 16, 2016 at 08:21:31PM +0200, 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
What is the general idea behind the "todo monad"? As an unrepented
procrastinator, I might learn something useful. _______________________________________________ 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.

For sure you need to be able to add stuff to the todo list ;)
On Aug 16, 2016 8:27 PM, "Francesco Ariis"
On Tue, Aug 16, 2016 at 08:21:31PM +0200, 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
What is the general idea behind the "todo monad"? As an unrepented procrastinator, I might learn something useful. _______________________________________________ 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.

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.

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.

I have a hunch that the desired behavior is Either b [a], tho. (Or
This was in reply to Theodore's message: possibly [Either b a]?) On 08/16/2016 11:12 PM, David Kraeutmann 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.

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
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.

Hi Corentin,
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.
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.
Chris
On Aug 17, 2016 09:56, "Corentin Dupont"
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
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.

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"
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
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.
participants (8)
-
Chris Wong
-
Corentin Dupont
-
David Feuer
-
David Kraeutmann
-
eyeinsky .
-
Francesco Ariis
-
Jules Mazur
-
Mihai Maruseac