CTRex icon indicating copy to clipboard operation
CTRex copied to clipboard

Define Label as an instance of IsLabel from

Open bgaster opened this issue 6 years ago • 2 comments

Is there any reason to not add an instance of IsLabel, import GHC.OverloadedLabels, for Label? A suitable instance, for example, is:

instance l ~ l' => IsLabel (l :: Symbol) (Label l') where
   fromLabel = Label

This could then be combined with the RebindableSyntax extension, allowing labels to be written simply as #s, for example, which would be translated to:

fromLabel @s

and used in the context where a Label was expected would cause that instance to be selected. I've added this to OpenRecords.hs (HEAD) and did some simple tests, so far seems to work as expected.

bgaster avatar Oct 04 '18 21:10 bgaster

No reason, the OverloadedLabels extension did not exist yet when writing this library. Maybe you can create a pull request?

atzeus avatar Nov 06 '18 13:11 atzeus

Will do.

bgaster avatar Nov 10 '18 08:11 bgaster