Yesod Monoid instance for Endo [Header]

Hi All, I've been working my way through Yesod and noticed an irregularity. The GGHanlder monad stack (Yesod/Handler.hs) type GHInner s m monad a = ReaderT (HandlerData s m) ( ErrorT HandlerContents ( WriterT (Endo [Header]) ( StateT GHState monad ) ) ) a has a WriterT member based on "Endo [Header]", which is locally defined as type Endo a = a -> a Therefore, unless I'm missing something, the Writer T Monoid instance must be Monoid b => Monoid (a -> b) Monoid [a] (i.e., an environment to list construct). Assuming the results a finally extracted by applying [] (an empty environment), this would mean addHeader = GHandler . lift . lift . tell . (:) degrades to (++), giving non-constant time concatenation. I'm thinking what was really meant was to use the Endo Monoid instance, thereby gaining the constant-time concatenation via function composition. Cheers! -Tyson

On Wed, Jun 8, 2011 at 9:25 PM, Tyson Whitehead
Hi All,
I've been working my way through Yesod and noticed an irregularity.
The GGHanlder monad stack (Yesod/Handler.hs)
type GHInner s m monad a = ReaderT (HandlerData s m) ( ErrorT HandlerContents ( WriterT (Endo [Header]) ( StateT GHState monad ) ) ) a
has a WriterT member based on "Endo [Header]", which is locally defined as
type Endo a = a -> a
Therefore, unless I'm missing something, the Writer T Monoid instance must be
Monoid b => Monoid (a -> b) Monoid [a]
(i.e., an environment to list construct). Assuming the results a finally extracted by applying [] (an empty environment), this would mean
addHeader = GHandler . lift . lift . tell . (:)
degrades to (++), giving non-constant time concatenation.
I'm thinking what was really meant was to use the Endo Monoid instance, thereby gaining the constant-time concatenation via function composition.
Cheers! -Tyson
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel
Hi Tyson, Awesome catch, that's most definitely what was intended. I'll apply a patch. Thanks, Michael
participants (2)
-
Michael Snoyman
-
Tyson Whitehead