5 | | `#a :: forall x. M.X -> x` is desugared to `M.a :: M.X -> Y` where `Y` depends |
6 | | on the concrete type of `M.a`. All it does is strip the module part off off |
7 | | the argument type, and look for the symbol `a` in that module. The module |
8 | | must be imported qualified for the resolution to happen, so compiling a |
| 5 | `#field :: f a b -> c` must have a known type for `a`, and is desugared to `M.field` where `M` |
| 6 | is the module that the type of `a` is defined in. Note that (->) is a special |
| 7 | case of the binary type constructor `f`, so `#field :: M.Rec -> a` is desugared |
| 8 | to `M.field`. |
| 9 | |
| 10 | The module must be imported qualified for the resolution to happen, so compiling a |
25 | | This is enough for field access, but to support convenient modification, some |
26 | | notion of lenses has to be built in and the rule has to be modified, from |
27 | | `#a :: forall x. M.X -> x` ==> `M.a :: M.X -> Y` to look at the first argument |
28 | | of a `Lens` class: |
29 | | `#a :: forall x. Lens M.X x` ==> `M.a :: Lens M.X Y`. Effectively this is |
30 | | just substituting `Lens` for `(->)`. Maybe it could be extended to look at |
31 | | the first argument of any type constructor `forall m x. m M.X x`, that way |
32 | | the syntax can be used to resolve not just record fields, but any function, |
33 | | or any member of Category, or whatever. |
| 27 | This is enough for field access, but to support convenient modification we |
| 28 | can use lenses. If we substitute `Lens` for `f` instead of (->), then |
| 29 | we can write `#field :: Lens M.Rec a -> b` and still have it resolve to `M.field`. |