Looking at the code, it seems pretty straightforward. LensRules
have a function lensField :: String -> Maybe String
(which either gives the name for a lens or fails). So you can make a function like
myMakeLenses = makeLensesWith $ lensRules
& lensField .~ (\name -> Just (name ++ "L"))
and use that instead of makeLenses
. Of course you could parameterize your function on (++ "L")
.
Or you could write it inline if you prefer, e.g.
makeLensesWith ?? ''Foo $ lensRules
& lensField .~ (\name -> Just (name ++ "L"))
(Note that (??)
is just infix flip
for passing the arguments in the right order. You can think of it as a "hole" in this case that the second argument get filled into. And (&)
is just flipped ($)
.)