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:

  1. yes, telling [a] has quadratic complexity in writer. can avoided using dlist (which uses codensity-like trick talking about) or datatype mappend isn't o(n^2).

  2. on top of that, writer generates thunks each >>= used build computation. problem because unlike first case can't worked around. solution use state monad instead.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -