[web-devel] Yesod Monoid instance for Endo [Header]
twhitehead at gmail.com
Wed Jun 8 20:25:11 CEST 2011
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
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)
(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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 490 bytes
Desc: This is a digitally signed message part.
More information about the web-devel