[Haskell-cafe] streaming with logs / metadata
Olaf Klinke
olf at aatal-apotheke.de
Mon Apr 8 19:04:27 UTC 2019
Dear Evan,
Probably you want to have a look whether the mtl package has something for you.
Anything beyond the Functor instance for (Either e), though, models exceptions that abort the computation as soon as the first Left arises. You seem to use the type in a different way which may be one reason why you do not find your functions implemented elsewhere. For logging or warnings, most Haskellers use something like a writer monad transformer. The underlying monad,
Writer w a = (w,a)
for some monoid w, is exceptionally versatile because of the function
Functor f => Writer w (f a) -> f (Writer w a)
which in combination with traverse lets you move the (Writer w) type in and out of nested types easily.
Cheers,
Olaf
More information about the Haskell-Cafe
mailing list