Created
August 20, 2020 11:51
-
-
Save paolino/4a457e52dd7c4d171a69a5c91ae484e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
dependencies: | |
- lens | |
- template-haskell | |
create all lenses for a record type preponing an l_ | |
-} | |
import Control.Lens ((.~), lensRules, lensField, makeLensesWith, DefName(TopName), FieldNamer) | |
import Language.Haskell.TH (DecsQ, Name, nameBase, mkName) | |
allLNamer :: FieldNamer | |
allLNamer _ _ n = pure $ TopName $ mkName ('l': '_' : nameBase n) | |
makeLLenses :: Name -> DecsQ | |
makeLLenses = makeLensesWith (lensField .~ allLNamer $ lensRules ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment