haskell - What is complexity of Control.Monad.Writer for w ~ [a]? -
assuming tell = flip mappend should quadratic, make writer instance pretty useless. if it's so, can done improve performance?
i'm thinking of trick used in control.monad.free.church control.monad.codensity: should possible reassociate mappend calls, codensity reassociates >>=, haven't figured how exactly.
to sum up:
yes,
telling[a]has quadratic complexity inwriter. can avoided usingdlist(which usescodensity-like trick talking about) or datatypemappendisn'to(n^2).on top of that,
writergenerates thunks each>>=used build computation. problem because unlike first case can't worked around. solution usestatemonad instead.
Comments
Post a Comment