kazu-yamamoto / logger

A fast logging system for Haskell
159 stars 68 forks source link

Eq and Show instances for LogStr? #137

Closed debug-ito closed 6 years ago

debug-ito commented 7 years ago

Is there any particular reason why LogStr is not instance of Eq or Show? If it was, it'd be handy for me to test them in my unit tests.

I think the main limitation is that Builder is not Eq or Show. I suggest using fromLogStr to implement them.

For example,

import qualified Data.ByteString.Char8 as BC

instance Show LogStr where
  show = show . BC.unpack . fromLogStr

instance Eq LogStr where
  a == b = (fromLogStr a) == (fromLogStr b)
kazu-yamamoto commented 7 years ago

The reason is that Builder is not instance of Eq nor Show.

I don't have strong opinions about your suggestion. If you really want that instances, please make a PR. I think that parentheses are not necessary in instance Eq.

debug-ito commented 7 years ago

OK, I'll make a PR. Thanks for the comment!