I guess you have a point here:
1. The definition of the MonadWriter operations does not need the Monoid
operations.
Hence, the class constraint Monoid w should be removed.
2. The formulation of the MonadWriter laws (which are sadly missing from
the documentation) would need the Monoid
Hi Petr,
On Sun, Dec 9, 2012 at 7:59 AM, Petr P petr@gmail.com wrote:
The class is defined as
class (Monoid w, Monad m) = MonadWriter w m | m - w where
...
What is the reason for the Monoid constrait? It seems superfluous to me. I
recompiled the whole package without it, with no
* Edward Z. Yang ezy...@mit.edu [2012-12-08 15:45:54-0800]
Second, even *if* the above holds (two tells are equivalent to one
tell), then there is *some* function f such that
tell w1 tell w2 == tell (f w1 w2)
It isn't necessary that f coincides with mappend, or even that the
Hi all,
I'd say that a type class declares functions and specifies laws (in the
docs)
what its implementations must adhere to. It's not the job of a type class to
fulfill the laws, it's the job of its implementations. So the reason for
'Monoid w' in 'MonadWriter' cannot be that then
An additional thought: I'd say 'contained' is sort of inverse to 'writer':
writer = contained = id
contained . writer = return
Petr Pudlak
2012/12/9 Petr P petr@gmail.com
Hi all,
I'd say that a type class declares functions and specifies laws (in the
docs)
what its
The class is defined as
class (Monoid w, Monad m) = MonadWriter w m | m - w where
...
What is the reason for the Monoid constrait? It seems superfluous to me. I
recompiled the whole package without it, with no problems.
Of course, the Monoid constraint is necessary for most _instances_,
The monoid instance is necessary to ensure adherence to the monad laws.
Cheers,
Edward
Excerpts from Petr P's message of Sat Dec 08 10:59:25 -0800 2012:
The class is defined as
class (Monoid w, Monad m) = MonadWriter w m | m - w where
...
What is the reason for the Monoid constrait?
* Edward Z. Yang ezy...@mit.edu [2012-12-08 11:19:01-0800]
The monoid instance is necessary to ensure adherence to the monad laws.
This doesn't make any sense to me. Are you sure you're talking about the
MonadWriter class and not about the Writer monad?
Roman
Excerpts from Roman Cheplyaka's message of Sat Dec 08 14:00:52 -0800 2012:
* Edward Z. Yang ezy...@mit.edu [2012-12-08 11:19:01-0800]
The monoid instance is necessary to ensure adherence to the monad laws.
This doesn't make any sense to me. Are you sure you're talking about the
MonadWriter
* Edward Z. Yang ezy...@mit.edu [2012-12-08 14:18:38-0800]
Excerpts from Roman Cheplyaka's message of Sat Dec 08 14:00:52 -0800 2012:
* Edward Z. Yang ezy...@mit.edu [2012-12-08 11:19:01-0800]
The monoid instance is necessary to ensure adherence to the monad laws.
This doesn't make any
The only thing we can tell from the Monad laws is that that function f
should be associative.
That f is associative is a very small step away from f forming a monoid.
What about listen :: m a - m (w, a)? What laws should it hold that are
compatible with those of the monad and those of tell?
Am 08.12.2012 um 23:18 schrieb Edward Z. Yang:
Excerpts from Roman Cheplyaka's message of Sat Dec 08 14:00:52 -0800 2012:
* Edward Z. Yang ezy...@mit.edu [2012-12-08 11:19:01-0800]
The monoid instance is necessary to ensure adherence to the monad laws.
This doesn't make any sense to me.
First of all, I don't see why two tells should be equivalent to one
tell. Imagine a MonadWriter that additionally records the number of
times 'tell' has been called. (You might argue that your last equation
should be a MonadWriter class law, but that's a different story — we're
talking about
Excerpts from Holger Siegel's message of Sat Dec 08 15:27:38 -0800 2012:
For deriving a monoid instance of w from monad (Writer w), you will need
function execWriter:: Writer w a - w, but in case of a general instance of
(MonadWriter w m) you would have to use function listen :: m a - m (a, w)
Am 09.12.2012 um 00:27 schrieb Holger Siegel:
For deriving a monoid instance of w from monad (Writer w), you will need
function execWriter:: Writer w a - w, but in case of a general instance of
(MonadWriter w m) you would have to use function listen :: m a - m (a, w)
that will only provide
15 matches
Mail list logo