Good morning all,
I have now split Richard's commit in two, so that it's explicit in the commit history that we are adding those instances:
Ben: I have briefly tried to add the Hlint annotations, but it turned out to be trickier than anticipated. I couldn't find any easy way in HLint to add a custom hint on a *typeclass instance*, and adding something like this into `compiler/.hlint.yaml` didn't change anything:
- modules:
- {name: GHC.Data.Bag, badidents: [mempty], message: "Use emptyBag as it's more descriptive"}
- {name: GHC.Data.Bag, badidents: [(<>)], message: "Use unionBags as it's more descriptive"}
(I suspect that's not what's the badidents syntax is for). I have also tried to add two `ANN` to the definitions, like this:
{-# ANN (<>) ("HLint: use unionBags as it's more descriptive" :: String) #-}
instance Semigroup (Bag a) where
(<>) = unionBags
However, this won't work as (<>) is imported qualified and there is no way in the ANN syntax to specify a fully qualified identifier. However, I suspect this is not the correct syntax either, as `(<>)` is really the *typeclass* method, but we want to target the particular instance implementation.
Having said that, Richard carefully defined `(<>) = unionBags` and `mempty = emptyBag`, so I agree that using `(<>)` and `mempty` would be more opaque but at the end of the day it should have the asymptotic complexity than using `unionBags` and `emptyBag` (modulo dictionary passing, but I hope that won't each our lunch).
A.