Skip to content

Capability focusing using lens? #105

Open
@andrevidela

Description

@andrevidela

Hi, apologies, this is neither a feature request nor a bug report. But a question that I did not know where else to ask.

Is there a way to derive a capability using a lens into a state? I understand that the Field/HasField and Pos/HasPos capabilities relate to their lens counterpats. But in my case I have a lens

view :: a -> b 
view = ...
update :: a -> b -> a
update = ...

and a capability HasState "stateName" b and I would like to turn it into a HasState "stateName" a using the lens described above. The ideal type signature would be something like
focus :: HasState t b m => Lens a b -> (forall m' . HasState t a m' => m' r) -> m r

Is there a way to achieve this?

Intuitively, I would assume zoom achieves that but I do not see what transformer to use or how to even define one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions