co-log/co-log-polysemy

A question of integrating with polysemy

berberman opened this issue · 3 comments

When using the custom effect Log provided by co-log-polysemy:

log :: forall msg r. Member (Log msg) r => msg -> Sem r ()

I want the type variable msg be Message, which is defined in Colog.Message, providing some friendly and convenient ways to handle with severity and callstack in logging. However, it seems that the series of functions(logDebug, logInfo, etc.) won't work well, since polysemy does not provide MonadReader instance to satisfy WithLog env msg m constraint, which is required by those functions. And I don't think using LogAction to wrap Sem directly is a good idea. To some extent, I have a sort of intuition that I am still coding with the mtl nested hell :P Anyway, can we have some functions constructing messages without involving the reader environment?

Hi @berberman, I think it would be good to have more parts of the co-log library reusable 🙂 But need to think to have nice reusability, but also having lightweight dependencies and an adequate number of packages 🤔

@berberman - maybe I haven't understood the problem in it's entirety, but couldn't you just add and use simple helper methods in your code (maybe one for each severity if you want to hide this type)? Like:

log :: HasCallStack => Member (Log Message) r => Severity -> Text -> Sem r ()
log msgSeverity msgText = withFrozenCallStack (CP.log Msg { msgStack = callStack, .. })

I'm not entirely sure if things are still open here, so I'm closing the issue; If there is still something to be clarified, please open a new issue.