Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
arybczak committed Dec 4, 2023
1 parent 3247eb1 commit 04fcb82
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions optics-core/src/Optics/Label.hs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ type GenericLabelOpticContext repDefined name k s t a b =
, repDefined ~ (Defined (Rep s) && Defined (Rep t))
#endif
, Unless repDefined (NoLabelOpticError name k s t a b)
-- If a label starts with "_[A-Z]", assume it's a name of a constructor.
-- Otherwise, if it starts with "?[a-z]", assume it's a name of a partial
-- field. Otherwise it's a total field.
, k ~ If (CmpSymbol "_@" name == 'LT && CmpSymbol "_[" name == 'GT)
A_Prism
(If (CmpSymbol "?`" name == 'LT && CmpSymbol "?{" name == 'GT)
Expand Down Expand Up @@ -595,6 +598,8 @@ instance
) => GenericOptic repDefined name A_Lens s t a b where
genericOptic = gfieldImpl @name

-- | This instance can only be used via label syntax with GHC >= 9.6 since it's
-- the first release with unrestricted overloaded labels.
instance
( GAffineFieldImpl repDefined name s t a b
, origName ~ AppendSymbol "?" name
Expand Down

0 comments on commit 04fcb82

Please sign in to comment.