
Before I go into crazy suggestions, have you looked at the Writer monad?
On Jun 4, 2016 9:25 AM, "martin"
Hello all,
I find myself frequentlly writing types like this
data Logger a l = Lgr { runLogger :: a -> Log l -> (Log l, Logger a l) }
The purpose is to give a logger a chance to carry an internal state. It
invocations. To do this it must keep track of how many times it has been called. I want to leave such things private to the Logger.
(1) I know that this is not an unusal thing to do, but it has an OO feel to it. Is there a more functional alternative to it. Should I just not worry?
(2) I can write a combinator which creates a Logger from a list of Loggers. Since each Logger potentially returns a new version of itself, I must always re-assemble the combined logger from all
this is a costly operation, particularly when most Loggers just return
could e.g. choose to log only every n the returned new versions. I am worried that themselves unaltered. I don't have any hard
numbers about the performance penalty though.
These Loggers are used in a discrete-event-simulation and they will get called many times (once for each event), but only occastionally actually write to the Log. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe