snoyberg / monad-logger

A class of monads which can log messages
MIT License
37 stars 22 forks source link

msg type for non-TH logging specialised to Text #24

Closed mpilgrem closed 4 years ago

mpilgrem commented 4 years ago

The non-TH logging functions were introduced in monad-logger-0.3.2.0. They are built on logWithoutLoc, which has been exported since 0.3.23, or logCS. The type of logWithoutLoc is:

logWithoutLoc :: (MonadLogger m, ToLogStr msg) => LogSource -> LogLevel -> msg -> m ()

but the logging functions are more specialised in the message type (Text), for example:

logDebugNS :: MonadLogger m => LogSource -> Text -> m ()
logDebugNS src = logWithoutLoc src LevelDebug

logCS also has a generalised msg.

Is there anything preventing these functions from having the more general type (given that a Text instance for toLogStr msg is exported)? For example:

logDebugNS :: (MonadLogger m, ToLogStr msg) => LogSource -> msg -> m ()

If there is not a barrier, I will propose a pull request.

snoyberg commented 4 years ago

Making such a change is a breaking change, since it breaks type inference. That's generally why Text can be preferable

mpilgrem commented 4 years ago

Thank you. I'll close the issue then.