New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Monoidal messages with QualifiedDo #28
Comments
Message
data type monoidMessage
data type Semigroup
I think we can reuse Currently we have: data Message = Message
{ messageSeverity :: !Severity
, messageStack :: !CallStack
, messageText :: !Text
}
data RichMessage (m :: Type -> Type) = RichMessage
{ richMessageMsg :: !Message
, richMessageMap :: !(FieldMap m)
} What I propose is to perform the following refactoring: data Message m = Message
{ messagePure :: FieldMap Identity -- but here should be Map from containers
, messageRich :: FieldMap m -- and here is still array
} We can construct and perform The generalisation is easy, we only need to add couple extra instances for Currently we do: log Debug "Some text..." If we want to add extra argument to log [ #severity Debug, #msg "Some Text" ] So it's completely extensible and users can do whatever they want with the library! But the cost is more verbose logging call. But I hope that with |
Message
data type Semigroup
I finally found an acceptable solution to this problem! Since GHC 9.0 we can use log $ Message.do
severityB Debug
userIdB userId Once Structured logging is implemented, we will get messages-as-monoids for free, since in structured logging messages are key-value maps. But this |
This is required for
extend
function. Would be interesting (but difficult) think on the way how to makeMessage
data type extensible as well.The text was updated successfully, but these errors were encountered: