Skip to content

Define Label as an instance of IsLabel from #15

@bgaster

Description

@bgaster

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions