Skip to content

Commit

Permalink
labels: extract predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
amesgen committed Mar 29, 2024
1 parent 688e41e commit 3475ce6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions generic-lens/src/Data/Generics/Labels.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,20 @@ type family ClassifyLabel (name :: Symbol) :: LabelType where
ClassifyLabel name =
If (StartsWithDigit name)
'PositionType
( If (CmpSymbol "_@" name == 'LT && CmpSymbol "_[" name == 'GT)
( If (StartsWithUnderscoreAndUpperCase name)
'LegacyConstrType
( If (CmpSymbol "@" name == 'LT && CmpSymbol "[" name == 'GT)
( If (StartsWithUpperCase name)
'ConstrType
'FieldType
)
)

type StartsWithUnderscoreAndUpperCase name =
CmpSymbol "_@" name == 'LT && CmpSymbol "_[" name == 'GT

type StartsWithUpperCase name =
CmpSymbol "@" name == 'LT && CmpSymbol "[" name == 'GT

instance ( labelType ~ ClassifyLabel name
, IsLabelHelper labelType name p f s t a b
, pafb ~ p a (f b), psft ~ p s (f t)) => IsLabel name (pafb -> psft) where
Expand Down

0 comments on commit 3475ce6

Please sign in to comment.