Ok, this is a usability question. Say that I have this code:
module Record (Record, changeRecord) where
data Record = {
_foo :: String,
_bar :: Int
}
makeLenses ''Record
changeRecord :: Record -> Record
changeRecord = undefined
I like to have the -Werror
in my compiler, but then this code flags the -Werror=unused-top-binds
for lenses foo
and bar
and to me this is perfectly fine same way I haven’t used _foo
and _bar
in my module.
So solutions that I’ve thinked of are:
- Use
makeLensesFor
but then I’m doing extra boilerplate just to satisfy the compiler. - Split this module in 2 files,
Types.hs
with Record and Lenses declaration fully open and exported and thenRecord.hs
importingTypes.hs
and reexporting theRecord
type but not theRecord
constructor. This solution to me “pollutes” the file/module structure of the project with extra nexting (ieRecord/Types.hs
)
So I wonder if someone has a solution that:
- Still keeps the
unused-top-binds
warning for the functions I define but not for the lenses - Hides the internal implementation of the type and doesn’t exports constructors.