I am learning about monads in the book 'Learn You a Haskell for Great Good!' by Miran Lipovaca. I am reading about how the Control.Monad.Writer module exports the Writer w a type along with its Monad instance and some useful functions for dealing with values of this type.
It gives a Writer type declaration example.
For the following code:
-- Writer w a corresponding to (a, w) <--- the order is reversed
newtype Writer w a = Writer { runWriter :: (a, w) } -- <--- (a, w)
Here, why is the pair type order reversed?
Can I make the declaration of Writer type like this?
-- Writer w a corresponding to (w, a) <--- same order with Writer w a
newtype Writer w a = Writer { runWriter :: (w, a) } -- <--- (w, a)
If I took the second choice of Writer type declaration, Is there anything bad influence in writing Haskell?
In order to find out Writer Monad, I have tried reading Haskell Writer Monad Source Code
(From https://hackage.haskell.org/package/transformers-0.6.0.4/docs/src/Control.Monad.Trans.Writer.Strict.html#WriterT)
newtype WriterT w m a = WriterT { runWriterT :: m (a, w) }
The pair type order is also reversed. Why can't define it like this?
newtype WriterT w m a = WriterT { runWriterT :: m (w, a) }
Is there any reason for this?
Thanks for your help.