Skip to content

Generalize "focus" lens to subrecords #14

@Lysxia

Description

@Lysxia

What do you think of a lens to operate on a subset of fields:

multifocus :: Functor f => proxy r -> (Rec u -> f (Rec v)) -> Rec (u :++ r) -> f (Rec (v :++ r))

Ideally I expected multifocus = const unsafeCoerce but this breaks if the user creates a new record Rec v "from scratch" instead of using the Rec u provided by the lens.

For instance, it might be useful to resolve this Motor issue. And more generally this may help alleviate some problems with row-polymorphism due to the fact that it isn't obvious to GHC that adding a field then removing it always results in a record of the same type as the one we started with.

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