pdonadeo / ocaml-lens

Private extraction of astrada's lens library
56 stars 9 forks source link

Option for lens definition in submodule #5

Closed ghost closed 7 years ago

ghost commented 7 years ago

Could there be an option like prefix, but instead it creates a Foo.Lens sub-module?

With that feature, one could use the lens function without function name noise or shadowing the record identifiers.

module Foo = struct
  type t = { foo : f_t; bar : bar_t } [@@deriving lens { module = true }]
end

let get_foo a = Foo.Lens.( a |. foo)
pdonadeo commented 7 years ago

@didier-wenzek do you think you have time to add this feature?

didier-wenzek commented 7 years ago

This is a nice idea. I'll take the time to make a pull request this week.

pdonadeo commented 7 years ago

@didier-wenzek thanks. I'm not familiar with ppx_deriving, so I'm waiting for your pull request to merge and release.

ghost commented 7 years ago

@pdonadeo same thing here with ppx_deriving.

didier-wenzek commented 7 years ago

On my side, I have trouble with oasis :-(. I failed to launch ppx_test. The dependency to lens.ppx_deriving is missing on make test while correctly requested in _oasis. This is not blocking. I have a workaround using directly ocamlbuild.

For ppx_deriving, a must have are the tools of https://github.com/alainfrisch/ppx_tools. For instance, I use ocamlfind ppx_tools/dumpast to generate the AST shape of the code to derive.

ghost commented 7 years ago

@didier-wenzek did you get past the dependency issues?

didier-wenzek commented 7 years ago

I managed to code & test the feature using a workaround for the tests (I compiled the tests using a hand-written _tags file). This is not compatible with oasis and a bit convoluted (Hence, I did not add these changes in the pull request).

Beyond this issue, things went fine. I submitted a pull request https://github.com/pdonadeo/ocaml-lens/pull/6.

I changed the name of the option to submodule = true since using the term module leads to syntax errors.

pdonadeo commented 7 years ago

@didier-wenzek... I'm giving up with the tests. @orbifx I'm going to release today.

pdonadeo commented 7 years ago

1.2.0 released on GitHub, I'm going to submit to the opam repository.