{-# LANGUAGE ImplicitPrelude #-}

module PlutusLedgerApi.Test.ScriptContextBuilder.Lenses.TH
  ( makeLensesWithL
  ) where

import Control.Lens qualified as L
import Language.Haskell.TH (DecsQ, Name)

{-| Uses 'makeLensesWith' to automatically create lens fields, but adds the 'L'
suffix to each lens field name. -}
makeLensesWithL :: Name -> DecsQ
makeLensesWithL :: Name -> DecsQ
makeLensesWithL = LensRules -> Name -> DecsQ
L.makeLensesWith (LensRules
L.defaultFieldRules LensRules -> (LensRules -> LensRules) -> LensRules
forall a b. a -> (a -> b) -> b
L.& (FieldNamer -> Identity FieldNamer)
-> LensRules -> Identity LensRules
Lens' LensRules FieldNamer
L.lensField ((FieldNamer -> Identity FieldNamer)
 -> LensRules -> Identity LensRules)
-> FieldNamer -> LensRules -> LensRules
forall s t a b. ASetter s t a b -> b -> s -> t
L..~ (String -> [String]) -> FieldNamer
L.mappingNamer (\String
s -> [String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"L"]))