├── milk.opam ├── .vscode └── settings.json ├── dune-project ├── example ├── for_codemodding │ ├── hello-reason.opam │ ├── dune-project │ ├── run_codemod.sh │ ├── bin │ │ ├── dune │ │ └── Hello.re │ ├── esy.lock │ │ ├── .gitignore │ │ ├── .gitattributes │ │ ├── opam │ │ │ ├── ocamlfind.1.8.0 │ │ │ │ ├── files │ │ │ │ │ ├── ocaml-stub │ │ │ │ │ └── ocamlfind.install │ │ │ │ └── opam │ │ │ ├── base-unix.base │ │ │ │ └── opam │ │ │ ├── base-threads.base │ │ │ │ └── opam │ │ │ ├── base-bytes.base │ │ │ │ └── opam │ │ │ ├── jbuilder.transition │ │ │ │ └── opam │ │ │ ├── easy-format.1.3.1 │ │ │ │ └── opam │ │ │ ├── cppo.1.6.5 │ │ │ │ └── opam │ │ │ ├── conf-which.1 │ │ │ │ └── opam │ │ │ ├── seq.0.1 │ │ │ │ └── opam │ │ │ ├── biniou.1.2.0 │ │ │ │ └── opam │ │ │ ├── conf-m4.1 │ │ │ │ └── opam │ │ │ ├── ppx_derivers.1.0 │ │ │ │ └── opam │ │ │ ├── result.1.3 │ │ │ │ └── opam │ │ │ ├── merlin-extend.0.3 │ │ │ │ └── opam │ │ │ ├── odoc.1.3.0 │ │ │ │ └── opam │ │ │ ├── ocamlbuild.0.12.0 │ │ │ │ └── opam │ │ │ ├── fpath.0.7.2 │ │ │ │ └── opam │ │ │ ├── uchar.0.0.2 │ │ │ │ └── opam │ │ │ ├── menhir.20181113 │ │ │ │ └── opam │ │ │ ├── ocaml-migrate-parsetree.1.2.0 │ │ │ │ └── opam │ │ │ ├── rresult.0.6.0 │ │ │ │ └── opam │ │ │ ├── re.1.8.0 │ │ │ │ └── opam │ │ │ ├── yojson.1.6.0 │ │ │ │ └── opam │ │ │ ├── tyxml.4.3.0 │ │ │ │ └── opam │ │ │ ├── astring.0.8.3 │ │ │ │ └── opam │ │ │ ├── uutf.1.0.2 │ │ │ │ └── opam │ │ │ ├── fmt.0.8.5 │ │ │ │ └── opam │ │ │ ├── cmdliner.1.0.3 │ │ │ │ └── opam │ │ │ ├── bos.0.2.0 │ │ │ │ └── opam │ │ │ ├── dune.1.6.3 │ │ │ │ └── opam │ │ │ ├── topkg.1.0.0 │ │ │ │ └── opam │ │ │ ├── logs.0.6.2 │ │ │ │ └── opam │ │ │ └── merlin.3.2.2 │ │ │ │ └── opam │ │ └── overrides │ │ │ ├── opam__s__dune_opam__c__1.6.3_opam_override │ │ │ └── package.json │ │ │ ├── opam__s__merlin_extend_opam__c__0.3_opam_override │ │ │ ├── package.json │ │ │ └── files │ │ │ │ └── merlin-extend-winfix.patch │ │ │ ├── opam__s__ocamlbuild_opam__c__0.12.0_opam_override │ │ │ └── package.json │ │ │ └── opam__s__ocamlfind_opam__c__1.8.0_opam_override │ │ │ └── package.json │ ├── .gitignore │ ├── src │ │ ├── dune │ │ └── Util.re │ ├── .ci │ │ ├── utils │ │ │ ├── use-esy.yml │ │ │ ├── use-node.yml │ │ │ ├── create-docs.yml │ │ │ ├── publish-build-cache.yml │ │ │ └── restore-build-cache.yml │ │ ├── release-platform-setup.yml │ │ ├── cross-release.yml │ │ ├── build-platform.yml │ │ ├── pipelines-release.js │ │ └── release-postinstall.js │ ├── package.json │ ├── MIT-LICENSE │ ├── azure-pipelines.yml │ └── README.md ├── .gitattributes ├── .gitignore ├── esy.lock │ ├── .gitignore │ ├── .gitattributes │ └── index.json ├── src │ ├── Types.re │ ├── Ezjsonm.re │ ├── KitchenTypes.re │ ├── App.re │ └── AllTypes.re ├── types.json ├── package.json ├── package-lock.json ├── bsconfig.json ├── multi-types.json └── run_all.js ├── .npmignore ├── esy.lock ├── opam │ ├── seq.base │ │ ├── files │ │ │ ├── seq.install │ │ │ └── META.seq │ │ └── opam │ ├── ocamlfind.1.8.1 │ │ ├── files │ │ │ ├── ocaml-stub │ │ │ └── ocamlfind.install │ │ └── opam │ ├── base-unix.base │ │ └── opam │ ├── base-threads.base │ │ └── opam │ ├── base-bytes.base │ │ └── opam │ ├── conf-m4.1 │ │ └── opam │ ├── ppx_derivers.1.2.1 │ │ └── opam │ ├── ppx_tools.6.2 │ │ └── opam │ ├── result.1.5 │ │ └── opam │ ├── ocaml-compiler-libs.v0.12.1 │ │ └── opam │ ├── menhir.20200624 │ │ └── opam │ ├── menhirLib.20200624 │ │ └── opam │ ├── ppx_tools_versioned.5.4.0 │ │ └── opam │ ├── menhirSdk.20200624 │ │ └── opam │ ├── stdio.v0.14.0 │ │ └── opam │ ├── stdlib-shims.0.1.0 │ │ └── opam │ ├── sexplib0.v0.14.0 │ │ └── opam │ ├── reason.3.5.2 │ │ └── opam │ ├── stringext.1.6.0 │ │ └── opam │ ├── ANSITerminal.0.8.1 │ │ └── opam │ ├── merlin-extend.0.5 │ │ └── opam │ ├── junit.2.0.2 │ │ └── opam │ ├── ocamlbuild.0.14.0 │ │ └── opam │ ├── uchar.0.0.2 │ │ └── opam │ ├── re.1.9.0 │ │ └── opam │ ├── cppo.1.6.6 │ │ └── opam │ ├── dune-private-libs.2.6.1 │ │ └── opam │ ├── uri.3.1.0 │ │ └── opam │ ├── base.v0.14.0 │ │ └── opam │ ├── dune-configurator.2.6.1 │ │ └── opam │ ├── ocaml-migrate-parsetree.1.7.3 │ │ └── opam │ ├── uutf.1.0.2 │ │ └── opam │ ├── tyxml.4.4.0 │ │ └── opam │ ├── ptime.0.8.5 │ │ └── opam │ ├── ppxlib.0.13.0 │ │ └── opam │ ├── topkg.1.0.1 │ │ └── opam │ └── dune.2.6.1 │ │ └── opam ├── .gitignore ├── .gitattributes └── overrides │ ├── opam__s__ocamlbuild_opam__c__0.14.0_opam_override │ └── package.json │ └── opam__s__ocamlfind_opam__c__1.8.1_opam_override │ └── package.json ├── .ci ├── use-node.yml ├── esy-build-steps.yml ├── publish-build-cache.yml └── restore-build-cache.yml ├── bin ├── dune └── Main.re ├── codemod-example ├── dune ├── Readme.md └── ExampleCodemod.re ├── codemod ├── dune ├── Codemod.re └── Helpers.re ├── src ├── serde │ ├── dune │ ├── Helpers.re │ ├── Engine.re │ ├── JsonCore.re │ └── OutputType.re ├── dune ├── type-map │ ├── dune │ ├── DigTypes.re │ ├── SerializeSimplerType.re │ └── GetTypeMap.re ├── type-map-serde │ ├── dune │ ├── TypeMapSerde.re │ ├── Config.re │ └── TransformHelpers.re ├── DigUtils.re ├── TypesFile.re ├── Lockfile.re └── Lockdown.re ├── .gitignore ├── package.json ├── types.json └── azure-pipelines.yml /milk.opam: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 1.6) 2 | -------------------------------------------------------------------------------- /example/for_codemodding/hello-reason.opam: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | src/Serde.ml binary 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | example 2 | _build 3 | _esy 4 | .vscode 5 | -------------------------------------------------------------------------------- /example/for_codemodding/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 1.0) 2 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | lib/ 2 | node_modules/ 3 | *.bs.js 4 | data.*.json 5 | -------------------------------------------------------------------------------- /esy.lock/opam/seq.base/files/seq.install: -------------------------------------------------------------------------------- 1 | lib:[ 2 | "META.seq" {"META"} 3 | ] 4 | -------------------------------------------------------------------------------- /esy.lock/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Reset any possible .gitignore, we want all esy.lock to be un-ignored. 3 | !* 4 | -------------------------------------------------------------------------------- /example/for_codemodding/run_codemod.sh: -------------------------------------------------------------------------------- 1 | ../../_build/install/default/bin/ExampleCodemod.exe ./src/Util.re 2 | -------------------------------------------------------------------------------- /example/esy.lock/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Reset any possible .gitignore, we want all esy.lock to be un-ignored. 3 | !* 4 | -------------------------------------------------------------------------------- /example/for_codemodding/bin/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name Hello) 3 | (public_name Hello) 4 | (libraries lib)) 5 | -------------------------------------------------------------------------------- /example/src/Types.re: -------------------------------------------------------------------------------- 1 | include AllTypes.V7; let version = "7"; let all_versions = ["1", "2", "2_1", "3", "4", "5", "6", "7"] -------------------------------------------------------------------------------- /example/esy.lock/.gitattributes: -------------------------------------------------------------------------------- 1 | 2 | # Set eol to LF so files aren't converted to CRLF-eol on Windows. 3 | * text eol=lf 4 | -------------------------------------------------------------------------------- /example/for_codemodding/bin/Hello.re: -------------------------------------------------------------------------------- 1 | Console.log("Running Test Program:"); 2 | let () = print_endline(Lib.Util.hello()); 3 | -------------------------------------------------------------------------------- /.ci/use-node.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - task: NodeTool@0 3 | displayName: 'Use Node 8.x' 4 | inputs: 5 | versionSpec: 8.x 6 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Reset any possible .gitignore, we want all esy.lock to be un-ignored. 3 | !* 4 | -------------------------------------------------------------------------------- /esy.lock/.gitattributes: -------------------------------------------------------------------------------- 1 | 2 | # Set eol to LF so files aren't converted to CRLF-eol on Windows. 3 | * text eol=lf linguist-generated 4 | -------------------------------------------------------------------------------- /example/for_codemodding/.gitignore: -------------------------------------------------------------------------------- 1 | .merlin 2 | node_modules/ 3 | _build 4 | _esy 5 | _release 6 | *.byte 7 | *.native 8 | *.install 9 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/.gitattributes: -------------------------------------------------------------------------------- 1 | 2 | # Set eol to LF so files aren't converted to CRLF-eol on Windows. 3 | * text eol=lf 4 | -------------------------------------------------------------------------------- /esy.lock/opam/ocamlfind.1.8.1/files/ocaml-stub: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BINDIR=$(dirname "$(command -v ocamlc)") 4 | "$BINDIR/ocaml" -I "$OCAML_TOPLEVEL_PATH" "$@" 5 | -------------------------------------------------------------------------------- /example/for_codemodding/src/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name lib) 3 | (flags (-w -40 -w +26)) 4 | (public_name hello-reason) 5 | (libraries console.lib pastel.lib)) 6 | -------------------------------------------------------------------------------- /example/for_codemodding/.ci/utils/use-esy.yml: -------------------------------------------------------------------------------- 1 | # steps to install esy globally 2 | 3 | steps: 4 | - script: "npm install -g esy@0.5.6" 5 | displayName: "install esy" 6 | -------------------------------------------------------------------------------- /example/src/Ezjsonm.re: -------------------------------------------------------------------------------- 1 | 2 | type value = 3 | [ `Null 4 | | `Bool(bool) 5 | | `Float(float) 6 | | `String(string) 7 | | `A(list(value)) 8 | | `O(list((string, value)))] 9 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/ocamlfind.1.8.0/files/ocaml-stub: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BINDIR=$(dirname "$(command -v ocamlc)") 4 | "$BINDIR/ocaml" -I "$OCAML_TOPLEVEL_PATH" "$@" 5 | -------------------------------------------------------------------------------- /esy.lock/opam/seq.base/files/META.seq: -------------------------------------------------------------------------------- 1 | name="seq" 2 | version="[distributed with OCaml 4.07 or above]" 3 | description="dummy backward-compatibility package for iterators" 4 | requires="" 5 | -------------------------------------------------------------------------------- /example/for_codemodding/.ci/utils/use-node.yml: -------------------------------------------------------------------------------- 1 | # steps to use node on agent 2 | 3 | steps: 4 | - task: NodeTool@0 5 | displayName: "Use Node 8.x" 6 | inputs: 7 | versionSpec: 8.x 8 | -------------------------------------------------------------------------------- /esy.lock/opam/base-unix.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "https://github.com/ocaml/opam-repository/issues" 3 | description: """ 4 | Unix library distributed with the OCaml compiler 5 | """ 6 | 7 | -------------------------------------------------------------------------------- /esy.lock/opam/base-threads.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "https://github.com/ocaml/opam-repository/issues" 3 | description: """ 4 | Threads library distributed with the OCaml compiler 5 | """ 6 | 7 | -------------------------------------------------------------------------------- /esy.lock/opam/ocamlfind.1.8.1/files/ocamlfind.install: -------------------------------------------------------------------------------- 1 | bin: [ 2 | "src/findlib/ocamlfind" {"ocamlfind"} 3 | "?src/findlib/ocamlfind_opt" {"ocamlfind"} 4 | "?tools/safe_camlp4" 5 | ] 6 | toplevel: ["src/findlib/topfind"] 7 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/base-unix.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "https://github.com/ocaml/opam-repository/issues" 3 | description: """ 4 | Unix library distributed with the OCaml compiler 5 | """ 6 | 7 | -------------------------------------------------------------------------------- /example/for_codemodding/src/Util.re: -------------------------------------------------------------------------------- 1 | 2 | module Belt_Result = { 3 | type t('a, 'b) = Ok('a) | Error('b); 4 | } 5 | open Belt_Result; 6 | 7 | let one = () => true ? Ok(5) : Error("hi"); 8 | 9 | let hello = () => "good"; 10 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/base-threads.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "https://github.com/ocaml/opam-repository/issues" 3 | description: """ 4 | Threads library distributed with the OCaml compiler 5 | """ 6 | 7 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/ocamlfind.1.8.0/files/ocamlfind.install: -------------------------------------------------------------------------------- 1 | bin: [ 2 | "src/findlib/ocamlfind" {"ocamlfind"} 3 | "?src/findlib/ocamlfind_opt" {"ocamlfind"} 4 | "?tools/safe_camlp4" 5 | ] 6 | toplevel: ["src/findlib/topfind"] 7 | -------------------------------------------------------------------------------- /esy.lock/opam/base-bytes.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: " " 3 | authors: " " 4 | homepage: " " 5 | depends: [ 6 | "ocaml" {>= "4.02.0"} 7 | "ocamlfind" {>= "1.5.3"} 8 | ] 9 | synopsis: "Bytes library distributed with the OCaml compiler" 10 | -------------------------------------------------------------------------------- /bin/dune: -------------------------------------------------------------------------------- 1 | 2 | (executable 3 | (name Main) 4 | (public_name milk) 5 | (libraries milk) 6 | (flags :standard -open Util -w -9-58) 7 | (preprocess (pps reason-language-server.Belt_ppx reason-language-server.Ppx_monads ppx_tools_versioned.metaquot_407)) 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/base-bytes.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: " " 3 | authors: " " 4 | homepage: " " 5 | depends: [ 6 | "ocaml" {>= "4.02.0"} 7 | "ocamlfind" {>= "1.5.3"} 8 | ] 9 | synopsis: "Bytes library distributed with the OCaml compiler" 10 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/overrides/opam__s__dune_opam__c__1.6.3_opam_override/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": [ 3 | [ 4 | "ocaml", 5 | "bootstrap.ml" 6 | ], 7 | [ 8 | "./boot.exe", 9 | "--release", 10 | "-j", 11 | "4" 12 | ] 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": [ 3 | [ 4 | "bash", 5 | "-c", 6 | "#{os == 'windows' ? 'patch -p1 < merlin-extend-winfix.patch' : 'true'}" 7 | ], 8 | [ 9 | "make" 10 | ] 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /example/types.json: -------------------------------------------------------------------------------- 1 | { 2 | "//": "AUTOGENERATED by run_all.js", 3 | "version": 7, 4 | "$schemaVersion": 2, 5 | "engines": { 6 | "Js.Json": { 7 | "output": "src/Serde.re" 8 | } 9 | }, 10 | "entries": [ 11 | { 12 | "file": "src/Types.re", 13 | "type": "household" 14 | } 15 | ], 16 | "custom": [] 17 | } -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "bs-platform": "^4.0.7" 4 | }, 5 | "scripts": { 6 | "start": "../_build/install/default/bin/milk types.json", 7 | "kitchen": "../_build/install/default/bin/milk multi-types.json", 8 | "try": "bsb -make-world && node ./src/App.bs.js", 9 | "build": "bsb -make-world" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /codemod-example/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name ExampleCodemod) 3 | (public_name ExampleCodemod.exe) 4 | (libraries Codemod reason-language-server.Util TypeMap compiler-libs.common ocaml-migrate-parsetree reason) 5 | (flags :standard -open Util -w -9) 6 | (preprocess (pps reason-language-server.Belt_ppx reason-language-server.Ppx_monads ppx_tools_versioned.metaquot_407))) -------------------------------------------------------------------------------- /codemod/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name Codemod) 3 | (public_name milk.Codemod) 4 | (libraries reason-language-server.Analyze reason-language-server.Util TypeMap compiler-libs.common ocaml-migrate-parsetree reason) 5 | (flags :standard -open Util -w -9) 6 | (preprocess (pps reason-language-server.Belt_ppx reason-language-server.Ppx_monads ppx_tools_versioned.metaquot_407)) 7 | ) -------------------------------------------------------------------------------- /example/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "requires": true, 3 | "lockfileVersion": 1, 4 | "dependencies": { 5 | "bs-platform": { 6 | "version": "4.0.7", 7 | "resolved": "https://registry.npmjs.org/bs-platform/-/bs-platform-4.0.7.tgz", 8 | "integrity": "sha512-39ZXSugB03PznE7eSVwxq5z4S8Cn44r22T2eFd7rgFQ94HaB/mCNHXG0epF3mJLYhhhyPT9w3e/t+FAIjSdAkg==" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/serde/dune: -------------------------------------------------------------------------------- 1 | 2 | (library 3 | (name Serde) 4 | (public_name milk.Serde) 5 | (libraries reason-language-server.Analyze reason-language-server.Util TypeMap compiler-libs.common ocaml-migrate-parsetree) 6 | (flags :standard -w -A -open Util) 7 | (preprocess (pps reason-language-server.Belt_ppx reason-language-server.Ppx_monads ppx_tools_versioned.metaquot_407)) 8 | ) 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/bsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "bsc-flags": ["-open Belt", "-bs-g"], 4 | "sources": [{ 5 | "dir" : "src", 6 | "subdirs" : true 7 | }], 8 | "warnings": { 9 | "number": "-44-27-45" 10 | }, 11 | "package-specs": [{ 12 | "module": "commonjs", 13 | "in-source": true 14 | }], 15 | "suffix": ".bs.js", 16 | "namespace": false, 17 | "refmt": 3 18 | } -------------------------------------------------------------------------------- /src/dune: -------------------------------------------------------------------------------- 1 | 2 | (library 3 | (public_name milk) 4 | ; (public_name milk) 5 | (libraries reason-language-server.Util TypeMap Serde TypeMapSerde reason compiler-libs.common ocaml-migrate-parsetree ppx_tools_versioned.metaquot_407) 6 | (flags :standard -open Util -w -A) 7 | (preprocess (pps reason-language-server.Belt_ppx reason-language-server.Ppx_monads ppx_tools_versioned.metaquot_407)) 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /src/type-map/dune: -------------------------------------------------------------------------------- 1 | 2 | (library 3 | (name TypeMap) 4 | (public_name milk.TypeMap) 5 | (libraries reason-language-server.Analyze reason-language-server.Util reason-language-server.Vendor compiler-libs.common ocaml-migrate-parsetree ppx_tools_versioned.metaquot_407) 6 | (flags :standard -w -A -open Util) 7 | (preprocess (pps reason-language-server.Belt_ppx reason-language-server.Ppx_monads ppx_tools_versioned.metaquot_407)) 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /src/type-map-serde/dune: -------------------------------------------------------------------------------- 1 | 2 | (library 3 | (name TypeMapSerde) 4 | (public_name milk.TypeMapSerde) 5 | (libraries TypeMap reason-language-server.Analyze reason-language-server.Util reason-language-server.Vendor compiler-libs.common ocaml-migrate-parsetree) 6 | (flags :standard -w -A -open Vendor -open Util) 7 | (preprocess (pps reason-language-server.Belt_ppx reason-language-server.Ppx_monads ppx_tools_versioned.metaquot_407)) 8 | ) 9 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .merlin 3 | .bsb.lock 4 | npm-debug.log 5 | /lib/ 6 | examples/**/lib 7 | examples/*/_build 8 | examples/*/_opam 9 | examples/*/node_modules 10 | node_modules 11 | node_modules/ 12 | log_types.txt 13 | *.install 14 | _esy 15 | _build 16 | _esy 17 | static/codemirror-5.36.0 18 | _old 19 | tmp 20 | *.vsix 21 | examples/markdown-reason-react/ 22 | editor-extensions/vscode/*.zip 23 | bsb_modules 24 | _esy/ 25 | bin.exe 26 | ExamplesTests.exe 27 | -------------------------------------------------------------------------------- /src/DigUtils.re: -------------------------------------------------------------------------------- 1 | open Migrate_parsetree.Ast_407; 2 | 3 | let hashList = tbl => Hashtbl.fold((key, value, result) => [(key, value), ...result], tbl, []); 4 | 5 | let makeModule = (moduleName, contents) => 6 | Ast_helper.Str.module_( 7 | Ast_helper.Mb.mk(Location.mknoloc(moduleName), Ast_helper.Mod.mk(Parsetree.Pmod_structure(contents))), 8 | ); 9 | 10 | let versionModuleName = version => "Version" ++ string_of_int(version); 11 | let typesModuleName = version => "Types" ++ string_of_int(version); -------------------------------------------------------------------------------- /esy.lock/opam/seq.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: " " 3 | authors: " " 4 | homepage: " " 5 | depends: [ 6 | "ocaml" {>= "4.07.0"} 7 | ] 8 | dev-repo: "git+https://github.com/ocaml/ocaml.git" 9 | bug-reports: "https://caml.inria.fr/mantis/main_page.php" 10 | synopsis: 11 | "Compatibility package for OCaml's standard iterator type starting from 4.07." 12 | extra-files: [ 13 | ["seq.install" "md5=026b31e1df290373198373d5aaa26e42"] 14 | ["META.seq" "md5=b33c8a1a6c7ed797816ce27df4855107"] 15 | ] 16 | -------------------------------------------------------------------------------- /example/multi-types.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "$schemaVersion": 2, 4 | "lockedTypes": "src/KitchenTypes.re", 5 | "engines": { 6 | "Js.Json": { 7 | "output": "src/KitchenSerde.re" 8 | }, 9 | "rex-json": { 10 | "output": "src/KitchenServerSerde.re" 11 | }, 12 | "ezjsonm": { 13 | "output": "src/KitchenEzSerde.re" 14 | } 15 | }, 16 | "entries": [ 17 | { 18 | "file": "src/AllTypes.re", 19 | "type": "All.rename", 20 | "publicName": "kitchenSink" 21 | } 22 | ], 23 | "custom": [] 24 | } -------------------------------------------------------------------------------- /example/for_codemodding/.ci/release-platform-setup.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | platform: "macOS" 3 | folder: "platform-darwin" 4 | 5 | steps: 6 | - task: DownloadBuildArtifacts@0 7 | displayName: "Download ${{ parameters.platform }} Artifacts" 8 | inputs: 9 | artifactName: ${{ parameters.platform }} 10 | downloadPath: $(Build.StagingDirectory) 11 | 12 | - script: "mkdir _release/${{ parameters.folder }}" 13 | displayName: "Create _release/${{ parameters.folder }}" 14 | 15 | - script: "cp -r $(Build.StagingDirectory)/${{ parameters.platform }}/ _release/${{ parameters.folder }}" 16 | displayName: "cp ${{ parameters.platform }}" 17 | -------------------------------------------------------------------------------- /src/serde/Helpers.re: -------------------------------------------------------------------------------- 1 | open Migrate_parsetree.Ast_407; 2 | open Longident; 3 | open Parsetree; 4 | open Ast_helper; 5 | open Asttypes; 6 | 7 | let loc = Location.none; 8 | 9 | let makeIdent = MakeSerializer.makeIdent; 10 | 11 | let failer = message => Exp.fun_(Nolabel, None, Pat.any(), 12 | Exp.apply(Exp.ident(Location.mknoloc(Lident("print_endline"))), [ 13 | (Nolabel, Exp.constant(Pconst_string(message, None))) 14 | ])); 15 | 16 | let rec makeList = items => switch items { 17 | | [] => Exp.construct(Location.mknoloc(Lident("[]")), None) 18 | | [one, ...rest] => Exp.construct(Location.mknoloc(Lident("::")), Some(Exp.tuple([ 19 | one, makeList(rest) 20 | ]))) 21 | }; -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/jbuilder.transition/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "opensource@janestreet.com" 3 | authors: ["Jane Street Group, LLC "] 4 | homepage: "https://github.com/ocaml/dune" 5 | bug-reports: "https://github.com/ocaml/dune/issues" 6 | dev-repo: "git+https://github.com/ocaml/dune.git" 7 | license: "MIT" 8 | depends: ["ocaml" "dune"] 9 | post-messages: [ 10 | "Jbuilder has been renamed and the jbuilder package is now a transition \ 11 | package. Use the dune package instead." 12 | ] 13 | synopsis: 14 | "This is a transition package, jbuilder is now named dune. Use the dune" 15 | description: "package instead." 16 | -------------------------------------------------------------------------------- /example/for_codemodding/.ci/utils/create-docs.yml: -------------------------------------------------------------------------------- 1 | # These steps are only run on Linux 2 | steps: 3 | - script: "esy doc" 4 | displayName: "Build docs" 5 | condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) 6 | 7 | - script: echo '##vso[task.setvariable variable=docsPath]'$(esy echo '#{self.target_dir}/default/_doc/_html') 8 | displayName: "Save docsPath in variable" 9 | condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) 10 | 11 | - task: PublishBuildArtifacts@1 12 | displayName: "Publish Artifact: Docs" 13 | condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) 14 | inputs: 15 | PathtoPublish: $(docsPath) 16 | ArtifactName: Docs 17 | -------------------------------------------------------------------------------- /.ci/esy-build-steps.yml: -------------------------------------------------------------------------------- 1 | # Cross-platform set of build steps for building esy projects 2 | 3 | steps: 4 | - script: npm install -g esy@0.5.6 5 | displayName: 'npm install -g esy@0.5.6' 6 | - script: esy install 7 | displayName: 'esy install' 8 | - script: esy build 9 | displayName: 'esy build' 10 | # Run tests or any additional steps here 11 | # - script: esy b dune runtest 12 | - bash: mkdir -p milk-release 13 | - bash: cp _build/default/bin/Main.exe milk-release/milk.exe 14 | - task: PublishBuildArtifacts@1 15 | displayName: 'Upload binary' 16 | inputs: 17 | pathToPublish: 'milk-release' 18 | artifactName: 'milk-$(Agent.OS)' 19 | parallel: true 20 | parallelCount: 8 21 | -------------------------------------------------------------------------------- /esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": [ 3 | [ 4 | "bash", 5 | "-c", 6 | "#{os == 'windows' ? 'patch -p1 < ocamlbuild-0.14.0.patch' : 'true'}" 7 | ], 8 | [ 9 | "make", 10 | "-f", 11 | "configure.make", 12 | "all", 13 | "OCAMLBUILD_PREFIX=#{self.install}", 14 | "OCAMLBUILD_BINDIR=#{self.bin}", 15 | "OCAMLBUILD_LIBDIR=#{self.lib}", 16 | "OCAMLBUILD_MANDIR=#{self.man}", 17 | "OCAMLBUILD_NATIVE=true", 18 | "OCAMLBUILD_NATIVE_TOOLS=true" 19 | ], 20 | [ 21 | "make", 22 | "check-if-preinstalled", 23 | "all", 24 | "#{os == 'windows' ? 'install' : 'opam-install'}" 25 | ] 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/easy-format.1.3.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "martin@mjambon.com" 3 | authors: ["Martin Jambon"] 4 | homepage: "http://mjambon.com/easy-format.html" 5 | bug-reports: "https://github.com/mjambon/easy-format/issues" 6 | dev-repo: "git+https://github.com/mjambon/easy-format.git" 7 | build: [ 8 | ["jbuilder" "build" "-p" name "-j" jobs] 9 | ["jbuilder" "runtest" "-p" name] {with-test} 10 | ] 11 | depends: [ 12 | "ocaml" {>= "4.02.3"} 13 | "jbuilder" {build} 14 | ] 15 | synopsis: 16 | "High-level and functional interface to the Format module of the OCaml standard library" 17 | url { 18 | src: "https://github.com/mjambon/easy-format/archive/v1.3.1.tar.gz" 19 | checksum: "md5=4e163700fb88fdcd6b8976c3a216c8ea" 20 | } 21 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.12.0_opam_override/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": [ 3 | [ 4 | "bash", 5 | "-c", 6 | "#{os == 'windows' ? 'patch -p1 < ocamlbuild-0.12.0.patch' : 'true'}" 7 | ], 8 | [ 9 | "make", 10 | "-f", 11 | "configure.make", 12 | "all", 13 | "OCAMLBUILD_PREFIX=#{self.install}", 14 | "OCAMLBUILD_BINDIR=#{self.bin}", 15 | "OCAMLBUILD_LIBDIR=#{self.lib}", 16 | "OCAMLBUILD_MANDIR=#{self.man}", 17 | "OCAMLBUILD_NATIVE=true", 18 | "OCAMLBUILD_NATIVE_TOOLS=true" 19 | ], 20 | [ 21 | "make", 22 | "check-if-preinstalled", 23 | "all", 24 | "#{os == 'windows' ? 'install' : 'opam-install'}" 25 | ] 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/cppo.1.6.5/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "martin@mjambon.com" 3 | authors: ["Martin Jambon"] 4 | homepage: "https://github.com/mjambon/cppo" 5 | dev-repo: "git+https://github.com/mjambon/cppo.git" 6 | bug-reports: "https://github.com/mjambon/cppo/issues" 7 | license: "BSD-3-Clause" 8 | 9 | build: [ 10 | ["jbuilder" "subst" "-p" name] {pinned} 11 | ["jbuilder" "build" "-p" name "-j" jobs] 12 | ["jbuilder" "runtest" "-p" name] {with-test} 13 | ] 14 | depends: [ 15 | "ocaml" 16 | "jbuilder" {build & >= "1.0+beta17"} 17 | "base-unix" 18 | ] 19 | synopsis: "Equivalent of the C preprocessor for OCaml programs" 20 | url { 21 | src: "https://github.com/mjambon/cppo/archive/v1.6.5.tar.gz" 22 | checksum: "md5=1cd25741d31417995b0973fe0b6f6c82" 23 | } 24 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/conf-which.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "unixjunkie@sdf.org" 3 | homepage: "http://www.gnu.org/software/which/" 4 | authors: "Carlo Wood" 5 | bug-reports: "https://github.com/ocaml/opam-repository/issues" 6 | license: "GPL-2+" 7 | build: [["which" "which"]] 8 | depexts: [ 9 | ["which"] {os-distribution = "centos"} 10 | ["which"] {os-distribution = "fedora"} 11 | ["which"] {os-family = "suse"} 12 | ["debianutils"] {os-distribution = "debian"} 13 | ["debianutils"] {os-distribution = "ubuntu"} 14 | ["which"] {os-distribution = "nixos"} 15 | ["which"] {os-distribution = "archlinux"} 16 | ] 17 | synopsis: "Virtual package relying on which" 18 | description: 19 | "This package can only install if the which program is installed on the system." 20 | flags: conf 21 | -------------------------------------------------------------------------------- /esy.lock/opam/conf-m4.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "tim@gfxmonk.net" 3 | homepage: "http://www.gnu.org/software/m4/m4.html" 4 | bug-reports: "https://github.com/ocaml/opam-repository/issues" 5 | authors: "GNU Project" 6 | license: "GPL-3.0-only" 7 | build: [["sh" "-exc" "echo | m4"]] 8 | depexts: [ 9 | ["m4"] {os-family = "debian"} 10 | ["m4"] {os-distribution = "fedora"} 11 | ["m4"] {os-distribution = "rhel"} 12 | ["m4"] {os-distribution = "centos"} 13 | ["m4"] {os-distribution = "alpine"} 14 | ["m4"] {os-distribution = "nixos"} 15 | ["m4"] {os-family = "suse"} 16 | ["m4"] {os-distribution = "ol"} 17 | ["m4"] {os-distribution = "arch"} 18 | ] 19 | synopsis: "Virtual package relying on m4" 20 | description: 21 | "This package can only install if the m4 binary is installed on the system." 22 | flags: conf 23 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/seq.0.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "simon.cruanes.2007@m4x.org" 3 | authors: "Simon Cruanes" 4 | homepage: "https://github.com/c-cube/seq/" 5 | bug-reports: "https://github.com/c-cube/seq/issues" 6 | license: "GPL" 7 | tags: ["iterator" "seq" "pure" "list" "compatibility" "cascade"] 8 | dev-repo: "git+https://github.com/c-cube/seq.git" 9 | build: [make "build"] 10 | install: [make "install"] 11 | remove: [ "ocamlfind" "remove" "seq" ] 12 | depends: [ 13 | "ocaml" {< "4.07.0"} 14 | "ocamlfind" {build} 15 | "ocamlbuild" {build} 16 | ] 17 | synopsis: 18 | "Compatibility package for OCaml's standard iterator type starting from 4.07." 19 | flags: light-uninstall 20 | url { 21 | src: "https://github.com/c-cube/seq/archive/0.1.tar.gz" 22 | checksum: "md5=0e87f9709541ed46ecb6f414bc31458c" 23 | } 24 | -------------------------------------------------------------------------------- /esy.lock/opam/ppx_derivers.1.2.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "jeremie@dimino.org" 3 | authors: ["Jérémie Dimino"] 4 | license: "BSD-3-Clause" 5 | homepage: "https://github.com/ocaml-ppx/ppx_derivers" 6 | bug-reports: "https://github.com/ocaml-ppx/ppx_derivers/issues" 7 | dev-repo: "git://github.com/ocaml-ppx/ppx_derivers.git" 8 | build: [ 9 | ["dune" "build" "-p" name "-j" jobs] 10 | ] 11 | depends: [ 12 | "ocaml" 13 | "dune" 14 | ] 15 | synopsis: "Shared [@@deriving] plugin registry" 16 | description: """ 17 | Ppx_derivers is a tiny package whose sole purpose is to allow 18 | ppx_deriving and ppx_type_conv to inter-operate gracefully when linked 19 | as part of the same ocaml-migrate-parsetree driver.""" 20 | url { 21 | src: "https://github.com/ocaml-ppx/ppx_derivers/archive/1.2.1.tar.gz" 22 | checksum: "md5=5dc2bf130c1db3c731fe0fffc5648b41" 23 | } 24 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/biniou.1.2.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "martin@mjambon.com" 3 | authors: ["Martin Jambon"] 4 | 5 | homepage: "https://github.com/mjambon/biniou" 6 | bug-reports: "https://github.com/mjambon/biniou/issues" 7 | dev-repo: "git+https://github.com/mjambon/biniou.git" 8 | license: "BSD-3-Clause" 9 | 10 | build: [ 11 | ["jbuilder" "build" "-p" name "-j" jobs] 12 | ["jbuilder" "runtest" "-p" name] {with-test} 13 | ] 14 | depends: [ 15 | "ocaml" {>= "4.02.3"} 16 | "conf-which" {build} 17 | "jbuilder" {build & >= "1.0+beta7"} 18 | "easy-format" 19 | ] 20 | synopsis: 21 | "Binary data format designed for speed, safety, ease of use and backward compatibility as protocols evolve" 22 | url { 23 | src: "https://github.com/mjambon/biniou/archive/v1.2.0.tar.gz" 24 | checksum: "md5=f3e92358e832ed94eaf23ce622ccc2f9" 25 | } 26 | -------------------------------------------------------------------------------- /esy.lock/opam/ppx_tools.6.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | synopsis: "Tools for authors of ppx rewriters and other syntactic tools" 3 | maintainer: "Kate " 4 | authors: "Alain Frisch " 5 | license: "MIT" 6 | tags: [ "syntax" ] 7 | homepage: "https://github.com/ocaml-ppx/ppx_tools" 8 | bug-reports: "https://github.com/ocaml-ppx/ppx_tools/issues" 9 | dev-repo: "git://github.com/ocaml-ppx/ppx_tools.git" 10 | build: ["dune" "build" "-p" name "-j" jobs] 11 | depends: [ 12 | "ocaml" {>= "4.08.0" & < "4.12.0"} 13 | "dune" {>= "1.6"} 14 | ] 15 | url { 16 | src: "https://github.com/ocaml-ppx/ppx_tools/archive/6.2.tar.gz" 17 | checksum: [ 18 | "md5=68b05e0794c475c384b9285d1156d1f3" 19 | "sha512=fc3943c69901ef46843355c3482d5a1481d05ee94fb0a344ec04101059a02cbaa76fed5742cfae82730edf378f2e140d859a5cf590653f85359255d451f07dc8" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /esy.lock/opam/result.1.5/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "opensource@janestreet.com" 3 | authors: ["Jane Street Group, LLC "] 4 | homepage: "https://github.com/janestreet/result" 5 | dev-repo: "git+https://github.com/janestreet/result.git" 6 | bug-reports: "https://github.com/janestreet/result/issues" 7 | license: "BSD-3-Clause" 8 | build: [["dune" "build" "-p" name "-j" jobs]] 9 | depends: [ 10 | "ocaml" 11 | "dune" {>= "1.0"} 12 | ] 13 | synopsis: "Compatibility Result module" 14 | description: """ 15 | Projects that want to use the new result type defined in OCaml >= 4.03 16 | while staying compatible with older version of OCaml should use the 17 | Result module defined in this library.""" 18 | url { 19 | src: 20 | "https://github.com/janestreet/result/releases/download/1.5/result-1.5.tbz" 21 | checksum: "md5=1b82dec78849680b49ae9a8a365b831b" 22 | } 23 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/conf-m4.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "tim@gfxmonk.net" 3 | homepage: "http://www.gnu.org/software/m4/m4.html" 4 | bug-reports: "https://github.com/ocaml/opam-repository/issues" 5 | authors: "GNU Project" 6 | license: "GPL-3" 7 | build: [["sh" "-exc" "echo | m4"]] 8 | depexts: [ 9 | ["m4"] {os-distribution = "debian"} 10 | ["m4"] {os-distribution = "ubuntu"} 11 | ["m4"] {os-distribution = "fedora"} 12 | ["m4"] {os-distribution = "rhel"} 13 | ["m4"] {os-distribution = "centos"} 14 | ["m4"] {os-distribution = "alpine"} 15 | ["m4"] {os-distribution = "nixos"} 16 | ["m4"] {os-family = "suse"} 17 | ["m4"] {os-distribution = "oraclelinux"} 18 | ["m4"] {os-distribution = "archlinux"} 19 | ] 20 | synopsis: "Virtual package relying on m4" 21 | description: 22 | "This package can only install if the m4 binary is installed on the system." 23 | flags: conf 24 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/ppx_derivers.1.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "jeremie@dimino.org" 3 | authors: ["Jérémie Dimino"] 4 | license: "BSD3" 5 | homepage: "https://github.com/ocaml-ppx/ppx_derivers" 6 | bug-reports: "https://github.com/ocaml-ppx/ppx_derivers/issues" 7 | dev-repo: "git://github.com/ocaml-ppx/ppx_derivers.git" 8 | build: [ 9 | ["jbuilder" "build" "-p" name "-j" jobs] 10 | ] 11 | depends: [ 12 | "ocaml" 13 | "jbuilder" {build & >= "1.0+beta7"} 14 | ] 15 | synopsis: "Shared [@@deriving] plugin registry" 16 | description: """ 17 | Ppx_derivers is a tiny package whose sole purpose is to allow 18 | ppx_deriving and ppx_type_conv to inter-operate gracefully when linked 19 | as part of the same ocaml-migrate-parsetree driver.""" 20 | url { 21 | src: "https://github.com/ocaml-ppx/ppx_derivers/archive/1.0.tar.gz" 22 | checksum: "md5=4ddce8f43fdb9b0ef0ab6a7cbfebc3e3" 23 | } 24 | -------------------------------------------------------------------------------- /example/for_codemodding/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-reason", 3 | "version": "0.1.0", 4 | "description": "Example Reason Esy Project", 5 | "license": "MIT", 6 | "esy": { 7 | "build": "refmterr dune build -p #{self.name}", 8 | "NOTE": "Optional release Section. Customizes result of `esy release`", 9 | "release": { 10 | "bin": [ 11 | "Hello" 12 | ] 13 | } 14 | }, 15 | "scripts": { 16 | "test": "esy x Hello", 17 | "doc": "esy dune build @doc" 18 | }, 19 | "dependencies": { 20 | "@opam/dune": "*", 21 | "@reason-native/console": "*", 22 | "@reason-native/pastel": "*", 23 | "@reason-native/rely": "*", 24 | "@esy-ocaml/reason": ">= 3.4.0 < 3.5.0", 25 | "refmterr": "*", 26 | "ocaml": "~4.6.0" 27 | }, 28 | "devDependencies": { 29 | "@opam/merlin": "*", 30 | "ocaml": "~4.6.0", 31 | "@opam/odoc": "*" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/result.1.3/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "opensource@janestreet.com" 3 | authors: ["Jane Street Group, LLC "] 4 | homepage: "https://github.com/janestreet/result" 5 | dev-repo: "git+https://github.com/janestreet/result.git" 6 | bug-reports: "https://github.com/janestreet/result/issues" 7 | license: "BSD3" 8 | build: [["jbuilder" "build" "-p" name "-j" jobs]] 9 | depends: [ 10 | "ocaml" 11 | "jbuilder" {build & >= "1.0+beta11"} 12 | ] 13 | synopsis: "Compatibility Result module" 14 | description: """ 15 | Projects that want to use the new result type defined in OCaml >= 4.03 16 | while staying compatible with older version of OCaml should use the 17 | Result module defined in this library.""" 18 | url { 19 | src: 20 | "https://github.com/janestreet/result/releases/download/1.3/result-1.3.tbz" 21 | checksum: "md5=4beebefd41f7f899b6eeba7414e7ae01" 22 | } 23 | -------------------------------------------------------------------------------- /esy.lock/opam/ocaml-compiler-libs.v0.12.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "opensource@janestreet.com" 3 | authors: ["Jane Street Group, LLC "] 4 | homepage: "https://github.com/janestreet/ocaml-compiler-libs" 5 | bug-reports: "https://github.com/janestreet/ocaml-compiler-libs/issues" 6 | dev-repo: "git+https://github.com/janestreet/ocaml-compiler-libs.git" 7 | license: "Apache-2.0" 8 | build: [ 9 | ["dune" "build" "-p" name "-j" jobs] 10 | ] 11 | depends: [ 12 | "ocaml" {>= "4.04.1"} 13 | "dune" {>= "1.5.1"} 14 | ] 15 | synopsis: "OCaml compiler libraries repackaged" 16 | description: """ 17 | This packages exposes the OCaml compiler libraries repackages under 18 | the toplevel names Ocaml_common, Ocaml_bytecomp, Ocaml_optcomp, ...""" 19 | url { 20 | src: 21 | "https://github.com/janestreet/ocaml-compiler-libs/archive/v0.12.1.tar.gz" 22 | checksum: "md5=2f929af7c764a3f681a5671f271210c4" 23 | } 24 | -------------------------------------------------------------------------------- /esy.lock/opam/menhir.20200624/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "francois.pottier@inria.fr" 3 | authors: [ 4 | "François Pottier " 5 | "Yann Régis-Gianas " 6 | ] 7 | homepage: "http://gitlab.inria.fr/fpottier/menhir" 8 | dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" 9 | bug-reports: "menhir@inria.fr" 10 | build: [ 11 | ["dune" "build" "-p" name "-j" jobs] 12 | ] 13 | depends: [ 14 | "ocaml" {>= "4.02.3"} 15 | "dune" { >= "2.2.0"} 16 | "menhirLib" {= version} 17 | "menhirSdk" {= version} 18 | ] 19 | synopsis: "An LR(1) parser generator" 20 | url { 21 | src: 22 | "https://gitlab.inria.fr/fpottier/menhir/repository/20200624/archive.tar.gz" 23 | checksum: [ 24 | "md5=c37ff53a4a69059e1f8223067b91bb8b" 25 | "sha512=68cd165bd65c93fc9b14820a032b6d760674b3e811d8536c2e26e10f9fc5892720564f109484f12f8d08d849c2983c2eaf350d76ab1122a5b8a3c7674ab2bd39" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /esy.lock/opam/menhirLib.20200624/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "francois.pottier@inria.fr" 3 | authors: [ 4 | "François Pottier " 5 | "Yann Régis-Gianas " 6 | ] 7 | homepage: "http://gitlab.inria.fr/fpottier/menhir" 8 | dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" 9 | bug-reports: "menhir@inria.fr" 10 | build: [ 11 | ["dune" "build" "-p" name "-j" jobs] 12 | ] 13 | depends: [ 14 | "ocaml" { >= "4.02.3" } 15 | "dune" { >= "2.0.0" } 16 | ] 17 | conflicts: [ 18 | "menhir" { != version } 19 | ] 20 | synopsis: "Runtime support library for parsers generated by Menhir" 21 | url { 22 | src: 23 | "https://gitlab.inria.fr/fpottier/menhir/repository/20200624/archive.tar.gz" 24 | checksum: [ 25 | "md5=c37ff53a4a69059e1f8223067b91bb8b" 26 | "sha512=68cd165bd65c93fc9b14820a032b6d760674b3e811d8536c2e26e10f9fc5892720564f109484f12f8d08d849c2983c2eaf350d76ab1122a5b8a3c7674ab2bd39" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /esy.lock/opam/ppx_tools_versioned.5.4.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | version: "5.4.0" 3 | maintainer: "frederic.bour@lakaban.net" 4 | authors: [ 5 | "Frédéric Bour " 6 | "Alain Frisch " 7 | ] 8 | license: "MIT" 9 | homepage: "https://github.com/ocaml-ppx/ppx_tools_versioned" 10 | bug-reports: "https://github.com/ocaml-ppx/ppx_tools_versioned/issues" 11 | dev-repo: "git://github.com/ocaml-ppx/ppx_tools_versioned.git" 12 | tags: [ "syntax" ] 13 | build: [ 14 | ["dune" "subst"] {pinned} 15 | ["dune" "build" "-p" name "-j" jobs] 16 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 17 | ] 18 | depends: [ 19 | "ocaml" {>= "4.02.0"} 20 | "dune" {>= "1.0"} 21 | "ocaml-migrate-parsetree" {>= "1.7.0"} 22 | ] 23 | synopsis: "A variant of ppx_tools based on ocaml-migrate-parsetree" 24 | url { 25 | src: "https://github.com/ocaml-ppx/ppx_tools_versioned/archive/5.4.0.tar.gz" 26 | checksum: "md5=3e809a11cae99f57c051d3d0100311f6" 27 | } 28 | -------------------------------------------------------------------------------- /esy.lock/opam/menhirSdk.20200624/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "francois.pottier@inria.fr" 3 | authors: [ 4 | "François Pottier " 5 | "Yann Régis-Gianas " 6 | ] 7 | homepage: "http://gitlab.inria.fr/fpottier/menhir" 8 | dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" 9 | bug-reports: "menhir@inria.fr" 10 | build: [ 11 | ["dune" "build" "-p" name "-j" jobs] 12 | ] 13 | depends: [ 14 | "ocaml" { >= "4.02.3" } 15 | "dune" { >= "2.0.0" } 16 | ] 17 | conflicts: [ 18 | "menhir" { != version } 19 | ] 20 | synopsis: "Compile-time library for auxiliary tools related to Menhir" 21 | url { 22 | src: 23 | "https://gitlab.inria.fr/fpottier/menhir/repository/20200624/archive.tar.gz" 24 | checksum: [ 25 | "md5=c37ff53a4a69059e1f8223067b91bb8b" 26 | "sha512=68cd165bd65c93fc9b14820a032b6d760674b3e811d8536c2e26e10f9fc5892720564f109484f12f8d08d849c2983c2eaf350d76ab1122a5b8a3c7674ab2bd39" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /example/for_codemodding/.ci/cross-release.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: utils/use-node.yml 3 | 4 | - script: "mkdir _release" 5 | displayName: "Create _release dir" 6 | 7 | - template: release-platform-setup.yml 8 | parameters: 9 | platform: "Linux" 10 | folder: "platform-linux" 11 | 12 | - template: release-platform-setup.yml 13 | parameters: 14 | platform: "macOS" 15 | folder: "platform-darwin" 16 | 17 | - template: release-platform-setup.yml 18 | parameters: 19 | platform: "Windows" 20 | folder: "platform-windows-x64" 21 | 22 | - script: "node .ci/pipelines-release.js" 23 | displayName: "node .ci/pipelines-release.js" 24 | continueOnError: true 25 | 26 | - script: "npm pack ." 27 | displayName: "npm pack" 28 | workingDirectory: "_release" 29 | 30 | - task: PublishBuildArtifacts@1 31 | displayName: "Publish Artifact: Release" 32 | inputs: 33 | PathtoPublish: "_release" 34 | ArtifactName: Release 35 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/merlin-extend.0.3/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Frederic Bour " 3 | authors: "Frederic Bour " 4 | homepage: "https://github.com/let-def/merlin-extend" 5 | bug-reports: "https://github.com/let-def/merlin-extend" 6 | license: "MIT" 7 | dev-repo: "git+https://github.com/let-def/merlin-extend.git" 8 | build: [make] 9 | install: [make "install"] 10 | remove: ["ocamlfind" "remove" "merlin_extend"] 11 | depends: [ 12 | "ocaml" {>= "4.02.3"} 13 | "ocamlfind" {build} 14 | "cppo" {build} 15 | ] 16 | synopsis: "A protocol to provide custom frontend to Merlin" 17 | description: """ 18 | This protocol allows to replace the OCaml frontend of Merlin. 19 | It extends what used to be done with the `-pp' flag to handle a few more cases.""" 20 | flags: light-uninstall 21 | url { 22 | src: "https://github.com/let-def/merlin-extend/archive/v0.3.tar.gz" 23 | checksum: "md5=9c6dfd4f53328f02f12fcc265f4e2dda" 24 | } 25 | -------------------------------------------------------------------------------- /codemod-example/Readme.md: -------------------------------------------------------------------------------- 1 | # Example Codemod 2 | 3 | Here's an example of a type-driven codemod! 4 | 5 | It finds functions that have a return type of `Belt.Result.t(int, string)`, and wraps the error payloads with `Unspecified`. 6 | 7 | 8 | So, for the file: 9 | ```reason 10 | open Result; 11 | 12 | let changeMe = (a, b, c) => Error("hello"); 13 | 14 | let nonCollapsible = something => 15 | if (something > 2) { 16 | Result.Ok(something); 17 | } else { 18 | Error("bad news"); 19 | }; 20 | ``` 21 | 22 | 23 | It rewrites as: 24 | ```reason 25 | open Result; 26 | 27 | let changeMe = (a, b, c) => Error("hello"); 28 | 29 | let nonCollapsible = something => 30 | if (something > 2) { 31 | Result.Ok(something); 32 | } else { 33 | Error(Unspecified("bad news")); 34 | }; 35 | ``` 36 | 37 | 38 | Note that the first `Error()` was not wrapped, because we specified that the `'ok` type had to be `int`. We could have left the `ok` type argument blank, and it would have picked that one up too. -------------------------------------------------------------------------------- /esy.lock/opam/stdio.v0.14.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "opensource@janestreet.com" 3 | authors: ["Jane Street Group, LLC "] 4 | homepage: "https://github.com/janestreet/stdio" 5 | bug-reports: "https://github.com/janestreet/stdio/issues" 6 | dev-repo: "git+https://github.com/janestreet/stdio.git" 7 | doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/stdio/index.html" 8 | license: "MIT" 9 | build: [ 10 | ["dune" "build" "-p" name "-j" jobs] 11 | ] 12 | depends: [ 13 | "ocaml" {>= "4.04.2"} 14 | "base" {>= "v0.14" & < "v0.15"} 15 | "dune" {>= "2.0.0"} 16 | ] 17 | synopsis: "Standard IO library for OCaml" 18 | description: " 19 | Stdio implements simple input/output functionalities for OCaml. 20 | 21 | It re-exports the input/output functions of the OCaml standard 22 | libraries using a more consistent API. 23 | " 24 | url { 25 | src: "https://ocaml.janestreet.com/ocaml-core/v0.14/files/stdio-v0.14.0.tar.gz" 26 | checksum: "md5=4cbdf15f0be88c3258aaeff9e04e00e9" 27 | } 28 | -------------------------------------------------------------------------------- /esy.lock/opam/stdlib-shims.0.1.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "The stdlib-shims programmers" 3 | authors: "The stdlib-shims programmers" 4 | homepage: "https://github.com/ocaml/stdlib-shims" 5 | doc: "https://ocaml.github.io/stdlib-shims/" 6 | dev-repo: "git+https://github.com/ocaml/stdlib-shims.git" 7 | bug-reports: "https://github.com/ocaml/stdlib-shims/issues" 8 | tags: ["stdlib" "compatibility" "org:ocaml"] 9 | license: ["typeof OCaml system"] 10 | depends: [ 11 | "dune" 12 | "ocaml" {>= "4.02.3"} 13 | ] 14 | build: [ "dune" "build" "-p" name "-j" jobs ] 15 | synopsis: "Backport some of the new stdlib features to older compiler" 16 | description: """ 17 | Backport some of the new stdlib features to older compiler, 18 | such as the Stdlib module. 19 | 20 | This allows projects that require compatibility with older compiler to 21 | use these new features in their code. 22 | """ 23 | url { 24 | src: 25 | "https://github.com/ocaml/stdlib-shims/releases/download/0.1.0/stdlib-shims-0.1.0.tbz" 26 | checksum: "md5=12b5704eed70c6bff5ac39a16db1425d" 27 | } 28 | -------------------------------------------------------------------------------- /esy.lock/opam/sexplib0.v0.14.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "opensource@janestreet.com" 3 | authors: ["Jane Street Group, LLC "] 4 | homepage: "https://github.com/janestreet/sexplib0" 5 | bug-reports: "https://github.com/janestreet/sexplib0/issues" 6 | dev-repo: "git+https://github.com/janestreet/sexplib0.git" 7 | doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/sexplib0/index.html" 8 | license: "MIT" 9 | build: [ 10 | ["dune" "build" "-p" name "-j" jobs] 11 | ] 12 | depends: [ 13 | "ocaml" {>= "4.04.2"} 14 | "dune" {>= "2.0.0"} 15 | ] 16 | synopsis: "Library containing the definition of S-expressions and some base converters" 17 | description: " 18 | Part of Jane Street's Core library 19 | The Core suite of libraries is an industrial strength alternative to 20 | OCaml's standard library that was developed by Jane Street, the 21 | largest industrial user of OCaml. 22 | " 23 | url { 24 | src: "https://ocaml.janestreet.com/ocaml-core/v0.14/files/sexplib0-v0.14.0.tar.gz" 25 | checksum: "md5=37aff0af8f8f6f759249475684aebdc4" 26 | } 27 | -------------------------------------------------------------------------------- /example/esy.lock/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "checksum": "c86bc5e0697caac1f7f39febcd65dee4", 3 | "root": "example@link-dev:./package.json", 4 | "node": { 5 | "example@link-dev:./package.json": { 6 | "id": "example@link-dev:./package.json", 7 | "name": "example", 8 | "version": "link-dev:./package.json", 9 | "source": { 10 | "type": "link-dev", 11 | "path": ".", 12 | "manifest": "package.json" 13 | }, 14 | "overrides": [], 15 | "dependencies": [ "bs-platform@4.0.18@d41d8cd9" ], 16 | "devDependencies": [] 17 | }, 18 | "bs-platform@4.0.18@d41d8cd9": { 19 | "id": "bs-platform@4.0.18@d41d8cd9", 20 | "name": "bs-platform", 21 | "version": "4.0.18", 22 | "source": { 23 | "type": "install", 24 | "source": [ 25 | "archive:https://registry.npmjs.org/bs-platform/-/bs-platform-4.0.18.tgz#sha1:d17b8693ba1f714d9b27e0ddb365f2069ba4b8a0" 26 | ] 27 | }, 28 | "overrides": [], 29 | "dependencies": [], 30 | "devDependencies": [] 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /example/for_codemodding/MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2016-2018 Various Authors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/odoc.1.3.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | 3 | name: "odoc" 4 | version: "1.3.0" 5 | homepage: "http://github.com/ocaml-doc/odoc" 6 | doc: "https://ocaml-doc.github.com/odoc/" 7 | bug-reports: "https://github.com/ocaml-doc/odoc/issues" 8 | license: "ISC" 9 | 10 | authors: [ 11 | "Thomas Refis " 12 | "David Sheets " 13 | "Leo White " 14 | ] 15 | maintainer: "Anton Bachin " 16 | dev-repo: "git+http://github.com/ocaml-doc/odoc.git" 17 | 18 | depends: [ 19 | "astring" {build} 20 | "bos" {build} 21 | "dune" {build} 22 | "cmdliner" {build} 23 | "cppo" {build} 24 | "fpath" {build} 25 | "ocaml" {build & >= "4.02.0"} 26 | "result" {build} 27 | "tyxml" {build & >= "4.0.0"} 28 | ] 29 | build: [ 30 | ["dune" "subst"] {pinned} 31 | ["dune" "build" "-p" name "-j" jobs] 32 | ] 33 | 34 | synopsis: "OCaml documentation generator" 35 | 36 | url { 37 | src: "https://github.com/ocaml/odoc/archive/1.3.0.tar.gz" 38 | checksum: "md5=c734b6ffc158b9519ef2c1463f5789ba" 39 | } 40 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jaredly/milk", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "types": "dune exec milk" 6 | }, 7 | "keywords": [ 8 | "Reason", 9 | "lsp", 10 | "IDE" 11 | ], 12 | "repository": { 13 | "url": "jaredly/milk", 14 | "type": "git" 15 | }, 16 | "description": "Milk 🥛 : Stress-free serialization & deserialization for Reason/OCaml", 17 | "author": "Jared Forsyth", 18 | "license": "ISC", 19 | "esy": { 20 | "build": "dune build -p milk", 21 | "buildsInSource": "_build" 22 | }, 23 | "dependencies": { 24 | "@opam/dune": "*", 25 | "@esy-ocaml/reason": "3.5.2", 26 | "@opam/ocaml-migrate-parsetree": "*", 27 | "@opam/ppx_tools_versioned": "*", 28 | "@opam/ppx_tools": "*", 29 | "rex-json": "*", 30 | "reason-language-server": "jaredly/reason-language-server#try", 31 | "ocaml": "~4.8.0" 32 | }, 33 | "resolutions": { 34 | "reason-language-server": "link:../reason-language-server" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /esy.lock/opam/reason.3.5.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Jordan Walke " 3 | authors: [ "Jordan Walke " ] 4 | license: "MIT" 5 | homepage: "https://github.com/facebook/reason" 6 | doc: "http://reasonml.github.io/" 7 | bug-reports: "https://github.com/facebook/reason/issues" 8 | dev-repo: "git://github.com/facebook/reason.git" 9 | tags: [ "syntax" ] 10 | build: [ 11 | ["dune" "build" "-p" name "-j" jobs] 12 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 13 | ] 14 | depends: [ 15 | "ocaml" {>= "4.02" & < "4.10"} 16 | "dune" {>= "1.4"} 17 | "ocamlfind" {build} 18 | "menhir" {>= "20170418"} 19 | "merlin-extend" {>= "0.4"} 20 | "result" 21 | "ocaml-migrate-parsetree" 22 | ] 23 | synopsis: "Reason: Syntax & Toolchain for OCaml" 24 | description: """ 25 | Reason gives OCaml a new syntax that is remniscient of languages like 26 | JavaScript. It's also the umbrella project for a set of tools for the OCaml & 27 | JavaScript ecosystem.""" 28 | url { 29 | src: "https://registry.npmjs.org/@esy-ocaml/reason/-/reason-3.5.2.tgz" 30 | checksum: "md5=66c54296009e0f6cbc8e93aa01105cbb" 31 | } 32 | -------------------------------------------------------------------------------- /esy.lock/opam/stringext.1.6.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "rudi.grinberg@gmail.com" 3 | authors: "Rudi Grinberg" 4 | license: "MIT" 5 | homepage: "https://github.com/rgrinberg/stringext" 6 | bug-reports: "https://github.com/rgrinberg/stringext/issues" 7 | depends: [ 8 | "ocaml" {>= "4.02.3"} 9 | "dune" {>= "1.0"} 10 | "ounit" {with-test} 11 | "qtest" {with-test & >= "2.2"} 12 | "base-bytes" 13 | ] 14 | build: [ 15 | ["dune" "subst"] {pinned} 16 | ["dune" "build" "-p" name "-j" jobs] 17 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 18 | ] 19 | dev-repo: "git+https://github.com/rgrinberg/stringext.git" 20 | synopsis: "Extra string functions for OCaml" 21 | description: """ 22 | Extra string functions for OCaml. Mainly splitting. All functions are in the 23 | Stringext module. 24 | """ 25 | url { 26 | src: 27 | "https://github.com/rgrinberg/stringext/releases/download/1.6.0/stringext-1.6.0.tbz" 28 | checksum: [ 29 | "sha256=db41f5d52e9eab17615f110b899dfeb27dd7e7f89cd35ae43827c5119db206ea" 30 | "sha512=d8ebe40f42b598a9bd99f1ef4b00ba93458385a4accd121af66a0bf3b3f8d7135f576740adf1a43081dd409977c2219fd4bdbb5b3d1308890d301d553ed49900" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /.ci/publish-build-cache.yml: -------------------------------------------------------------------------------- 1 | # Steps for publishing project cache 2 | 3 | steps: 4 | - bash: 'mkdir -p $(STAGING_DIRECTORY_UNIX)' 5 | condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) 6 | displayName: '[Cache][Publish] Create cache directory' 7 | 8 | - bash: 'cd $(ESY__CACHE_INSTALL_PATH) && tar -czf $(STAGING_DIRECTORY_UNIX)/esy-cache.tar .' 9 | workingDirectory: '' 10 | condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) 11 | displayName: '[Cache][Publish] Tar esy cache directory' 12 | 13 | # - bash: 'cd $(ESY__NPM_ROOT) && tar -czf $(STAGING_DIRECTORY_UNIX)/npm-cache.tar .' 14 | # condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) 15 | # displayName: '[Cache][Publish] Tar npm cache directory' 16 | 17 | - task: PublishBuildArtifacts@1 18 | displayName: '[Cache][Publish] Upload tarball' 19 | condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) 20 | inputs: 21 | pathToPublish: '$(STAGING_DIRECTORY)' 22 | artifactName: 'cache-$(Agent.OS)-install' 23 | parallel: true 24 | parallelCount: 8 25 | -------------------------------------------------------------------------------- /example/for_codemodding/.ci/utils/publish-build-cache.yml: -------------------------------------------------------------------------------- 1 | # Steps for publishing project cache 2 | 3 | steps: 4 | - bash: 'mkdir -p $(STAGING_DIRECTORY_UNIX)' 5 | condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) 6 | displayName: '[Cache][Publish] Create cache directory' 7 | 8 | - bash: 'cd $(ESY__CACHE_INSTALL_PATH) && tar -czf $(STAGING_DIRECTORY_UNIX)/esy-cache.tar .' 9 | workingDirectory: '' 10 | condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) 11 | displayName: '[Cache][Publish] Tar esy cache directory' 12 | 13 | # - bash: 'cd $(ESY__NPM_ROOT) && tar -czf $(STAGING_DIRECTORY_UNIX)/npm-cache.tar .' 14 | # condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) 15 | # displayName: '[Cache][Publish] Tar npm cache directory' 16 | 17 | - task: PublishBuildArtifacts@1 18 | displayName: '[Cache][Publish] Upload tarball' 19 | condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) 20 | inputs: 21 | pathToPublish: '$(STAGING_DIRECTORY)' 22 | artifactName: 'cache-$(Agent.OS)-install' 23 | parallel: true 24 | parallelCount: 8 25 | -------------------------------------------------------------------------------- /src/serde/Engine.re: -------------------------------------------------------------------------------- 1 | open Migrate_parsetree.Ast_407; 2 | 3 | module type T = { 4 | let target: Parsetree.core_type; 5 | let preamble: Parsetree.structure; 6 | let declDeserializer: 7 | ( 8 | ~helpers: option(string), 9 | ~renames: list((string, string)), 10 | ~moduleName: string, 11 | ~modulePath: list(string), 12 | ~name: string, 13 | ~inner: option(Parsetree.expression), 14 | SharedTypes.SimpleType.declaration( 15 | TypeMap.DigTypes.typeSource(TypeMap.DigTypes.shortReference), 16 | ) 17 | ) => 18 | Parsetree.value_binding; 19 | let declSerializer: 20 | ( 21 | ~helpers: option(string), 22 | ~renames: list((string, string)), 23 | ~moduleName: string, 24 | ~modulePath: list(string), 25 | ~name: string, 26 | SharedTypes.SimpleType.declaration( 27 | TypeMap.DigTypes.typeSource((string, list(string), string)), 28 | ) 29 | ) => 30 | Parsetree.value_binding; 31 | let serializeTransformer: MakeSerializer.transformer(TypeMap.DigTypes.typeSource(TypeMap.DigTypes.shortReference)); 32 | let deserializeTransformer: MakeDeserializer.transformer(TypeMap.DigTypes.typeSource(TypeMap.DigTypes.shortReference)); 33 | }; -------------------------------------------------------------------------------- /esy.lock/opam/ANSITerminal.0.8.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Christophe Troestler " 3 | authors: [ "Christophe Troestler" 4 | "Vincent Hugot" ] 5 | license: "LGPL-3.0-only with OCaml-LGPL-linking-exception" 6 | homepage: "https://github.com/Chris00/ANSITerminal" 7 | dev-repo: "git+https://github.com/Chris00/ANSITerminal.git" 8 | bug-reports: "https://github.com/Chris00/ANSITerminal/issues" 9 | doc: "https://Chris00.github.io/ANSITerminal/doc" 10 | tags: [ "terminal" ] 11 | build: [ 12 | ["dune" "subst"] {pinned} 13 | ["dune" "build" "-p" name "-j" jobs] 14 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 15 | ] 16 | depends: [ 17 | "ocaml" 18 | "dune" 19 | "base-bytes" 20 | "base-unix" 21 | ] 22 | synopsis: "Basic control of ANSI compliant terminals and the windows shell" 23 | description: """ 24 | ANSITerminal is a module allowing to use the colors and cursor 25 | movements on ANSI terminals. It also works on the windows shell (but 26 | this part is currently work in progress).""" 27 | url { 28 | src: 29 | "https://github.com/Chris00/ANSITerminal/releases/download/0.8.1/ANSITerminal-0.8.1.tbz" 30 | checksum: "md5=d9909496b5e47c75227453256198d1ae" 31 | } 32 | -------------------------------------------------------------------------------- /esy.lock/opam/merlin-extend.0.5/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Frederic Bour " 3 | authors: "Frederic Bour " 4 | homepage: "https://github.com/let-def/merlin-extend" 5 | bug-reports: "https://github.com/let-def/merlin-extend" 6 | license: "MIT" 7 | dev-repo: "git+https://github.com/let-def/merlin-extend.git" 8 | build: [ 9 | ["dune" "subst"] {pinned} 10 | ["dune" "build" "-p" name "-j" jobs] 11 | ] 12 | depends: [ 13 | "dune" {>= "1.0"} 14 | "cppo" {build} 15 | "ocaml" {>= "4.02.3" & < "4.11"} 16 | ] 17 | synopsis: "A protocol to provide custom frontend to Merlin" 18 | description: """ 19 | This protocol allows to replace the OCaml frontend of Merlin. 20 | It extends what used to be done with the `-pp' flag to handle a few more cases.""" 21 | doc: "https://let-def.github.io/merlin-extend" 22 | url { 23 | src: 24 | "https://github.com/let-def/merlin-extend/releases/download/v0.5/merlin-extend-v0.5.tbz" 25 | checksum: [ 26 | "sha256=ca3a38c360c7d4827eb4789abf7a6aa4b6e3b4e3c3ef69a5be64dce4601ec227" 27 | "sha512=55c5a3637337abb8ca8db679128a81ca8ccce567bc214d55b2e6444dc0e905b74c64d629bdea2457d0fe4be5306414feefcdbc4d4761fdafd59aa107550936b6" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.1_opam_override/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": [ 3 | [ 4 | "bash", 5 | "-c", 6 | "#{os == 'windows' ? 'patch -p1 < findlib-1.8.1.patch' : 'true'}" 7 | ], 8 | [ 9 | "./configure", 10 | "-bindir", 11 | "#{self.bin}", 12 | "-sitelib", 13 | "#{self.lib}", 14 | "-mandir", 15 | "#{self.man}", 16 | "-config", 17 | "#{self.lib}/findlib.conf", 18 | "-no-custom", 19 | "-no-topfind" 20 | ], 21 | [ 22 | "make", 23 | "all" 24 | ], 25 | [ 26 | "make", 27 | "opt" 28 | ] 29 | ], 30 | "install": [ 31 | [ 32 | "make", 33 | "install" 34 | ], 35 | [ 36 | "install", 37 | "-m", 38 | "0755", 39 | "ocaml-stub", 40 | "#{self.bin}/ocaml" 41 | ], 42 | [ 43 | "mkdir", 44 | "-p", 45 | "#{self.toplevel}" 46 | ], 47 | [ 48 | "install", 49 | "-m", 50 | "0644", 51 | "src/findlib/topfind", 52 | "#{self.toplevel}/topfind" 53 | ] 54 | ], 55 | "exportedEnv": { 56 | "OCAML_TOPLEVEL_PATH": { 57 | "val": "#{self.toplevel}", 58 | "scope": "global" 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/ocamlbuild.0.12.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Gabriel Scherer " 3 | authors: ["Nicolas Pouillard" "Berke Durak"] 4 | homepage: "https://github.com/ocaml/ocamlbuild/" 5 | bug-reports: "https://github.com/ocaml/ocamlbuild/issues" 6 | license: "LGPL-2 with OCaml linking exception" 7 | doc: "https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc" 8 | dev-repo: "git+https://github.com/ocaml/ocamlbuild.git" 9 | build: [ 10 | [ 11 | make 12 | "-f" 13 | "configure.make" 14 | "all" 15 | "OCAMLBUILD_PREFIX=%{prefix}%" 16 | "OCAMLBUILD_BINDIR=%{bin}%" 17 | "OCAMLBUILD_LIBDIR=%{lib}%" 18 | "OCAMLBUILD_MANDIR=%{man}%" 19 | "OCAML_NATIVE=%{ocaml:native}%" 20 | "OCAML_NATIVE_TOOLS=%{ocaml:native}%" 21 | ] 22 | [make "check-if-preinstalled" "all" "opam-install"] 23 | ] 24 | conflicts: [ 25 | "base-ocamlbuild" 26 | "ocamlfind" {< "1.6.2"} 27 | ] 28 | synopsis: 29 | "OCamlbuild is a build system with builtin rules to easily build most OCaml projects." 30 | depends: [ 31 | "ocaml" {>= "4.03" & < "4.08.0"} 32 | ] 33 | url { 34 | src: "https://github.com/ocaml/ocamlbuild/archive/0.12.0.tar.gz" 35 | checksum: "md5=442baa19470bd49150f153122e22907b" 36 | } 37 | -------------------------------------------------------------------------------- /esy.lock/opam/junit.2.0.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Louis Roché " 3 | authors: "Louis Roché " 4 | homepage: "https://github.com/Khady/ocaml-junit" 5 | bug-reports: "https://github.com/Khady/ocaml-junit/issues" 6 | license: "LGPLv3+ with OCaml linking exception" 7 | dev-repo: "git+https://github.com/Khady/ocaml-junit.git" 8 | doc: "https://khady.github.io/ocaml-junit/" 9 | tags: ["junit" "jenkins"] 10 | depends: [ 11 | "dune" {>= "1.0"} 12 | "ptime" 13 | "tyxml" {>= "4.0.0"} 14 | "odoc" {with-doc & >= "1.1.1"} 15 | ] 16 | build: [ 17 | ["dune" "subst"] {pinned} 18 | ["dune" "build" "-p" name "-j" jobs] 19 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 20 | ["dune" "build" "-p" name "-j" jobs] {with-doc} 21 | ] 22 | name: "junit" 23 | synopsis: "JUnit XML reports generation library" 24 | description: "JUnit XML reports generation library" 25 | url { 26 | src: 27 | "https://github.com/Khady/ocaml-junit/releases/download/2.0.2/junit-2.0.2.tbz" 28 | checksum: [ 29 | "sha256=fda941b653613a4a5731f9b3557364b12baa341daa13c01676c9eb8d64e96b01" 30 | "sha512=5a9fa803c4861748bb8482fc51197420bf3cc3b9540989a489c4ffb65fdd02386aaa60437eae29182209dae0903b0e537c095249e19d395a451b8e8214f15f03" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /esy.lock/opam/ocamlbuild.0.14.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Gabriel Scherer " 3 | authors: ["Nicolas Pouillard" "Berke Durak"] 4 | homepage: "https://github.com/ocaml/ocamlbuild/" 5 | bug-reports: "https://github.com/ocaml/ocamlbuild/issues" 6 | license: "LGPL-2.1-only with OCaml-LGPL-linking-exception" 7 | doc: "https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc" 8 | dev-repo: "git+https://github.com/ocaml/ocamlbuild.git" 9 | build: [ 10 | [ 11 | make 12 | "-f" 13 | "configure.make" 14 | "all" 15 | "OCAMLBUILD_PREFIX=%{prefix}%" 16 | "OCAMLBUILD_BINDIR=%{bin}%" 17 | "OCAMLBUILD_LIBDIR=%{lib}%" 18 | "OCAMLBUILD_MANDIR=%{man}%" 19 | "OCAML_NATIVE=%{ocaml:native}%" 20 | "OCAML_NATIVE_TOOLS=%{ocaml:native}%" 21 | ] 22 | [make "check-if-preinstalled" "all" "opam-install"] 23 | ] 24 | conflicts: [ 25 | "base-ocamlbuild" 26 | "ocamlfind" {< "1.6.2"} 27 | ] 28 | synopsis: 29 | "OCamlbuild is a build system with builtin rules to easily build most OCaml projects." 30 | depends: [ 31 | "ocaml" {>= "4.03"} 32 | ] 33 | url { 34 | src: "https://github.com/ocaml/ocamlbuild/archive/0.14.0.tar.gz" 35 | checksum: "sha256=87b29ce96958096c0a1a8eeafeb6268077b2d11e1bf2b3de0f5ebc9cf8d42e78" 36 | } 37 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.0_opam_override/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": [ 3 | [ 4 | "bash", 5 | "-c", 6 | "#{os == 'windows' ? 'patch -p1 < findlib-1.8.0.patch' : 'true'}" 7 | ], 8 | [ 9 | "./configure", 10 | "-bindir", 11 | "#{self.bin}", 12 | "-sitelib", 13 | "#{self.lib}", 14 | "-mandir", 15 | "#{self.man}", 16 | "-config", 17 | "#{self.lib}/findlib.conf", 18 | "-no-custom", 19 | "-no-topfind" 20 | ], 21 | [ 22 | "make", 23 | "all" 24 | ], 25 | [ 26 | "make", 27 | "opt" 28 | ] 29 | ], 30 | "install": [ 31 | [ 32 | "make", 33 | "install" 34 | ], 35 | [ 36 | "install", 37 | "-m", 38 | "0755", 39 | "ocaml-stub", 40 | "#{self.bin}/ocaml" 41 | ], 42 | [ 43 | "mkdir", 44 | "-p", 45 | "#{self.toplevel}" 46 | ], 47 | [ 48 | "install", 49 | "-m", 50 | "0644", 51 | "src/findlib/topfind", 52 | "#{self.toplevel}/topfind" 53 | ] 54 | ], 55 | "exportedEnv": { 56 | "OCAML_TOPLEVEL_PATH": { 57 | "val": "#{self.toplevel}", 58 | "scope": "global" 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /esy.lock/opam/uchar.0.0.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://ocaml.org" 5 | doc: "https://ocaml.github.io/uchar/" 6 | dev-repo: "git+https://github.com/ocaml/uchar.git" 7 | bug-reports: "https://github.com/ocaml/uchar/issues" 8 | tags: [ "text" "character" "unicode" "compatibility" "org:ocaml.org" ] 9 | license: "typeof OCaml system" 10 | depends: [ 11 | "ocaml" {>= "3.12.0"} 12 | "ocamlbuild" {build} 13 | ] 14 | build: [ 15 | ["ocaml" "pkg/git.ml"] 16 | [ 17 | "ocaml" 18 | "pkg/build.ml" 19 | "native=%{ocaml:native}%" 20 | "native-dynlink=%{ocaml:native-dynlink}%" 21 | ] 22 | ] 23 | synopsis: "Compatibility library for OCaml's Uchar module" 24 | description: """ 25 | The `uchar` package provides a compatibility library for the 26 | [`Uchar`][1] module introduced in OCaml 4.03. 27 | 28 | The `uchar` package is distributed under the license of the OCaml 29 | compiler. See [LICENSE](LICENSE) for details. 30 | 31 | [1]: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Uchar.html""" 32 | url { 33 | src: 34 | "https://github.com/ocaml/uchar/releases/download/v0.0.2/uchar-0.0.2.tbz" 35 | checksum: "md5=c9ba2c738d264c420c642f7bb1cf4a36" 36 | } 37 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/fpath.0.7.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://erratique.ch/software/fpath" 5 | doc: "http://erratique.ch/software/fpath/doc" 6 | dev-repo: "git+http://erratique.ch/repos/fpath.git" 7 | bug-reports: "https://github.com/dbuenzli/fpath/issues" 8 | tags: [ "file" "system" "path" "org:erratique" ] 9 | license: "ISC" 10 | depends: [ 11 | "ocaml" {>= "4.01.0"} 12 | "ocamlfind" {build} 13 | "ocamlbuild" {build} 14 | "topkg" {build & >= "0.9.0"} 15 | "result" 16 | "astring" 17 | ] 18 | build: [[ 19 | "ocaml" "pkg/pkg.ml" "build" 20 | "--dev-pkg" "%{pinned}%" ]] 21 | synopsis: "File system paths for OCaml" 22 | description: """ 23 | Fpath is an OCaml module for handling file system paths with POSIX or 24 | Windows conventions. Fpath processes paths without accessing the file 25 | system and is independent from any system library. 26 | 27 | Fpath depends on [Astring][astring] and is distributed under the ISC 28 | license. 29 | 30 | [astring]: http://erratique.ch/software/astring""" 31 | url { 32 | src: "http://erratique.ch/software/fpath/releases/fpath-0.7.2.tbz" 33 | checksum: "md5=52c7ecb0bf180088336f3c645875fa41" 34 | } 35 | -------------------------------------------------------------------------------- /esy.lock/opam/re.1.9.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | 3 | maintainer: "rudi.grinberg@gmail.com" 4 | authors: [ 5 | "Jerome Vouillon" 6 | "Thomas Gazagnaire" 7 | "Anil Madhavapeddy" 8 | "Rudi Grinberg" 9 | "Gabriel Radanne" 10 | ] 11 | license: "LGPL-2.0-only with OCaml-LGPL-linking-exception" 12 | homepage: "https://github.com/ocaml/ocaml-re" 13 | bug-reports: "https://github.com/ocaml/ocaml-re/issues" 14 | dev-repo: "git+https://github.com/ocaml/ocaml-re.git" 15 | 16 | build: [ 17 | ["dune" "subst"] {pinned} 18 | ["dune" "build" "-p" name "-j" jobs] 19 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 20 | ] 21 | 22 | depends: [ 23 | "ocaml" {>= "4.02"} 24 | "dune" 25 | "ounit" {with-test} 26 | "seq" 27 | ] 28 | 29 | synopsis: "RE is a regular expression library for OCaml" 30 | description: """ 31 | Pure OCaml regular expressions with: 32 | * Perl-style regular expressions (module Re.Perl) 33 | * Posix extended regular expressions (module Re.Posix) 34 | * Emacs-style regular expressions (module Re.Emacs) 35 | * Shell-style file globbing (module Re.Glob) 36 | * Compatibility layer for OCaml's built-in Str module (module Re.Str) 37 | """ 38 | url { 39 | src: 40 | "https://github.com/ocaml/ocaml-re/releases/download/1.9.0/re-1.9.0.tbz" 41 | checksum: "md5=bddaed4f386a22cace7850c9c7dac296" 42 | } 43 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/uchar.0.0.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://ocaml.org" 5 | doc: "https://ocaml.github.io/uchar/" 6 | dev-repo: "git+https://github.com/ocaml/uchar.git" 7 | bug-reports: "https://github.com/ocaml/uchar/issues" 8 | tags: [ "text" "character" "unicode" "compatibility" "org:ocaml.org" ] 9 | license: "typeof OCaml system" 10 | depends: [ 11 | "ocaml" {>= "3.12.0"} 12 | "ocamlbuild" {build} 13 | ] 14 | build: [ 15 | ["ocaml" "pkg/git.ml"] 16 | [ 17 | "ocaml" 18 | "pkg/build.ml" 19 | "native=%{ocaml:native}%" 20 | "native-dynlink=%{ocaml:native-dynlink}%" 21 | ] 22 | ] 23 | synopsis: "Compatibility library for OCaml's Uchar module" 24 | description: """ 25 | The `uchar` package provides a compatibility library for the 26 | [`Uchar`][1] module introduced in OCaml 4.03. 27 | 28 | The `uchar` package is distributed under the license of the OCaml 29 | compiler. See [LICENSE](LICENSE) for details. 30 | 31 | [1]: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Uchar.html""" 32 | url { 33 | src: 34 | "https://github.com/ocaml/uchar/releases/download/v0.0.2/uchar-0.0.2.tbz" 35 | checksum: "md5=c9ba2c738d264c420c642f7bb1cf4a36" 36 | } 37 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/menhir.20181113/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "francois.pottier@inria.fr" 3 | authors: [ 4 | "François Pottier " 5 | "Yann Régis-Gianas " 6 | ] 7 | homepage: "http://gitlab.inria.fr/fpottier/menhir" 8 | dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" 9 | bug-reports: "menhir@inria.fr" 10 | build: [ 11 | [make "-f" "Makefile" "PREFIX=%{prefix}%" "USE_OCAMLFIND=true" "docdir=%{doc}%/menhir" "libdir=%{lib}%/menhir" "mandir=%{man}%/man1"] 12 | ] 13 | install: [ 14 | [make "-f" "Makefile" "install" "PREFIX=%{prefix}%" "docdir=%{doc}%/menhir" "libdir=%{lib}%/menhir" "mandir=%{man}%/man1"] 15 | ] 16 | remove: [ 17 | [make "-f" "Makefile" "uninstall" "PREFIX=%{prefix}%" "docdir=%{doc}%/menhir" "libdir=%{lib}%/menhir" "mandir=%{man}%/man1"] 18 | ] 19 | depends: [ 20 | "ocaml" {>= "4.02"} 21 | "ocamlfind" {build} 22 | "ocamlbuild" {build} 23 | ] 24 | synopsis: "An LR(1) parser generator" 25 | url { 26 | src: 27 | "https://gitlab.inria.fr/fpottier/menhir/repository/20181113/archive.tar.gz" 28 | checksum: [ 29 | "md5=69ce441a06ea131cd43e7b44c4303f3c" 30 | "sha512=4ddefcd71d305bfb933a4056da57e36c13c99ec6dfcc4695814798fbbd78b4d65828381ebcb0e58c4c0394105ac763af3d475474e05e408f7080315bc3cf6176" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/ocaml-migrate-parsetree.1.2.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "frederic.bour@lakaban.net" 3 | authors: [ 4 | "Frédéric Bour " 5 | "Jérémie Dimino " 6 | ] 7 | license: "LGPL-2.1" 8 | homepage: "https://github.com/ocaml-ppx/ocaml-migrate-parsetree" 9 | bug-reports: "https://github.com/ocaml-ppx/ocaml-migrate-parsetree/issues" 10 | dev-repo: "git+https://github.com/ocaml-ppx/ocaml-migrate-parsetree.git" 11 | doc: "https://ocaml-ppx.github.io/ocaml-migrate-parsetree/" 12 | tags: [ "syntax" "org:ocamllabs" ] 13 | build: [ 14 | ["dune" "build" "-p" name "-j" jobs] 15 | ] 16 | depends: [ 17 | "result" 18 | "ppx_derivers" 19 | "dune" {build & >= "1.6.0"} 20 | "ocaml" {>= "4.02.3"} 21 | ] 22 | synopsis: "Convert OCaml parsetrees between different versions" 23 | description: """ 24 | Convert OCaml parsetrees between different versions 25 | 26 | This library converts parsetrees, outcometree and ast mappers between 27 | different OCaml versions. High-level functions help making PPX 28 | rewriters independent of a compiler version. 29 | """ 30 | url { 31 | src: 32 | "https://github.com/ocaml-ppx/ocaml-migrate-parsetree/releases/download/v1.2.0/ocaml-migrate-parsetree-v1.2.0.tbz" 33 | checksum: "md5=cc6fb09ad6f99156c7dba47711c62c6f" 34 | } 35 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/rresult.0.6.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://erratique.ch/software/rresult" 5 | doc: "http://erratique.ch/software/rresult" 6 | dev-repo: "git+http://erratique.ch/repos/rresult.git" 7 | bug-reports: "https://github.com/dbuenzli/rresult/issues" 8 | tags: [ "result" "error" "declarative" "org:erratique" ] 9 | license: "ISC" 10 | depends: [ 11 | "ocaml" {>= "4.01.0"} 12 | "ocamlfind" {build} 13 | "ocamlbuild" {build} 14 | "topkg" {build} 15 | "result" 16 | ] 17 | build:[[ 18 | "ocaml" "pkg/pkg.ml" "build" 19 | "--pinned" "%{pinned}%" ]] 20 | 21 | synopsis: """Result value combinators for OCaml""" 22 | description: """\ 23 | 24 | Rresult is an OCaml module for handling computation results and errors 25 | in an explicit and declarative manner, without resorting to 26 | exceptions. It defines combinators to operate on the `result` type 27 | available from OCaml 4.03 in the standard library. 28 | 29 | Rresult depends on the compatibility `result` package and is 30 | distributed under the ISC license. 31 | """ 32 | url { 33 | archive: "http://erratique.ch/software/rresult/releases/rresult-0.6.0.tbz" 34 | checksum: "aba88cffa29081714468c2c7bcdf7fb1" 35 | } 36 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/files/merlin-extend-winfix.patch: -------------------------------------------------------------------------------- 1 | --- ./extend_helper.ml 2 | +++ ./extend_helper.ml 3 | @@ -1,13 +1,6 @@ 4 | -(*pp cppo -V OCAML:`ocamlc -version` *) 5 | open Parsetree 6 | open Extend_protocol 7 | 8 | -#if OCAML_VERSION < (4, 3, 0) 9 | -# define CONST_STRING Asttypes.Const_string 10 | -#else 11 | -# define CONST_STRING Parsetree.Pconst_string 12 | -#endif 13 | - 14 | (** Default implementation for [Reader_def.print_outcome] using 15 | [Oprint] from compiler-libs *) 16 | let print_outcome_using_oprint ppf = function 17 | @@ -28,7 +21,7 @@ 18 | pstr_loc = Location.none; 19 | pstr_desc = Pstr_eval ({ 20 | pexp_loc = Location.none; 21 | - pexp_desc = Pexp_constant (CONST_STRING (msg, None)); 22 | + pexp_desc = Pexp_constant (Parsetree.Pconst_string (msg, None)); 23 | pexp_attributes = []; 24 | }, []); 25 | }] 26 | @@ -112,7 +105,7 @@ 27 | let msg = match payload with 28 | | PStr [{ 29 | pstr_desc = Pstr_eval ({ 30 | - pexp_desc = Pexp_constant (CONST_STRING (msg, _)); 31 | + pexp_desc = Pexp_constant (Parsetree.Pconst_string (msg, _)); 32 | }, _); 33 | }] -> msg 34 | | _ -> "Warning: extension produced an incorrect syntax-error node" 35 | -------------------------------------------------------------------------------- /esy.lock/opam/cppo.1.6.6/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "martin@mjambon.com" 3 | authors: "Martin Jambon" 4 | license: "BSD-3-Clause" 5 | homepage: "http://mjambon.com/cppo.html" 6 | doc: "https://ocaml-community.github.io/cppo/" 7 | bug-reports: "https://github.com/ocaml-community/cppo/issues" 8 | depends: [ 9 | "ocaml" {>= "4.03"} 10 | "dune" {>= "1.0"} 11 | "base-unix" 12 | ] 13 | build: [ 14 | ["dune" "subst"] {pinned} 15 | ["dune" "build" "-p" name "-j" jobs] 16 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 17 | ] 18 | dev-repo: "git+https://github.com/ocaml-community/cppo.git" 19 | synopsis: "Code preprocessor like cpp for OCaml" 20 | description: """ 21 | Cppo is an equivalent of the C preprocessor for OCaml programs. 22 | It allows the definition of simple macros and file inclusion. 23 | 24 | Cppo is: 25 | 26 | * more OCaml-friendly than cpp 27 | * easy to learn without consulting a manual 28 | * reasonably fast 29 | * simple to install and to maintain 30 | """ 31 | url { 32 | src: "https://github.com/ocaml-community/cppo/releases/download/v1.6.6/cppo-v1.6.6.tbz" 33 | checksum: [ 34 | "sha256=e7272996a7789175b87bb998efd079794a8db6625aae990d73f7b4484a07b8a0" 35 | "sha512=44ecf9d225d9e45490a2feac0bde04865ca398dba6c3579e3370fcd1ea255707b8883590852af8b2df87123801062b9f3acce2455c092deabf431f9c4fb8d8eb" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/re.1.8.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "rudi.grinberg@gmail.com" 3 | authors: [ 4 | "Jerome Vouillon" 5 | "Thomas Gazagnaire" 6 | "Anil Madhavapeddy" 7 | "Rudi Grinberg" 8 | "Gabriel Radanne" 9 | ] 10 | license: "LGPL-2.0 with OCaml linking exception" 11 | homepage: "https://github.com/ocaml/ocaml-re" 12 | bug-reports: "https://github.com/ocaml/ocaml-re/issues" 13 | dev-repo: "git+https://github.com/ocaml/ocaml-re.git" 14 | build: [ 15 | ["jbuilder" "subst" "-n" name] {pinned} 16 | ["jbuilder" "build" "-p" name "-j" jobs] 17 | ["jbuilder" "runtest" "-p" name "-j" jobs] {with-test} 18 | ] 19 | depends: [ 20 | "ocaml" {>= "4.02.3"} 21 | "jbuilder" {build & >= "1.0+beta10"} 22 | "ounit" {with-test} 23 | "seq" 24 | ] 25 | synopsis: "RE is a regular expression library for OCaml" 26 | description: """ 27 | Pure OCaml regular expressions with: 28 | * Perl-style regular expressions (module Re.Perl) 29 | * Posix extended regular expressions (module Re.Posix) 30 | * Emacs-style regular expressions (module Re.Emacs) 31 | * Shell-style file globbing (module Re.Glob) 32 | * Compatibility layer for OCaml's built-in Str module (module Re.Str)""" 33 | url { 34 | src: 35 | "https://github.com/ocaml/ocaml-re/releases/download/1.8.0/re-1.8.0.tbz" 36 | checksum: "md5=765f6f8d3e6ab200866e719ed7e5178d" 37 | } 38 | -------------------------------------------------------------------------------- /example/src/KitchenTypes.re: -------------------------------------------------------------------------------- 1 | [@ocaml.warning "-34"]; 2 | module Types1 = { 3 | type _AllTypes__All__normalRecord = 4 | AllTypes.All.normalRecord = { 5 | a: int, 6 | b: string, 7 | c: (int, (string, float)), 8 | d: array(int), 9 | e: list(float), 10 | f: option(int), 11 | } 12 | and _AllTypes__All__normalVariant = 13 | AllTypes.All.normalVariant = 14 | | A | B | C(int) | D(_AllTypes__All__normalRecord) 15 | and _AllTypes__All__parameterizedRecord('a, 'b) = 16 | AllTypes.All.parameterizedRecord('a, 'b) = { 17 | a: 'a, 18 | b: 'b, 19 | c: (int, float), 20 | d: _AllTypes__All__recursive, 21 | } 22 | and _AllTypes__All__parameterizedVariant('a, 'b) = 23 | AllTypes.All.parameterizedVariant('a, 'b) = 24 | | PA 25 | | PB('a) 26 | | PC('a, 'b) 27 | | PD(_AllTypes__All__parameterizedRecord('a, 'b)) 28 | | PE(_AllTypes__All__normalVariant) 29 | | PF(_AllTypes__All__normalRecord) 30 | and _AllTypes__All__recursive = 31 | AllTypes.All.recursive = | A | B(_AllTypes__All__recursive) 32 | and _AllTypes__All__rename = _AllTypes__All__top 33 | and _AllTypes__All__top = 34 | AllTypes.All.top = { 35 | contents: _AllTypes__All__parameterizedVariant(int, array(float)), 36 | title: string, 37 | }; 38 | }; 39 | let currentVersion = 1; 40 | -------------------------------------------------------------------------------- /esy.lock/opam/dune-private-libs.2.6.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | synopsis: "Private libraries of Dune" 3 | description: """ 4 | !!!!!!!!!!!!!!!!!!!!!! 5 | !!!!! DO NOT USE !!!!! 6 | !!!!!!!!!!!!!!!!!!!!!! 7 | 8 | This package contains code that is shared between various dune-xxx 9 | packages. However, it is not meant for public consumption and provides 10 | no stability guarantee. 11 | """ 12 | maintainer: ["Jane Street Group, LLC "] 13 | authors: ["Jane Street Group, LLC "] 14 | license: "MIT" 15 | homepage: "https://github.com/ocaml/dune" 16 | doc: "https://dune.readthedocs.io/" 17 | bug-reports: "https://github.com/ocaml/dune/issues" 18 | depends: [ 19 | "dune" {>= "2.5"} 20 | "ocaml" {>= "4.07"} 21 | ] 22 | dev-repo: "git+https://github.com/ocaml/dune.git" 23 | build: [ 24 | ["dune" "subst"] {pinned} 25 | [ 26 | "dune" 27 | "build" 28 | "-p" 29 | name 30 | "-j" 31 | jobs 32 | "@install" 33 | "@doc" {with-doc} 34 | ] 35 | ] 36 | url { 37 | src: "https://github.com/ocaml/dune/releases/download/2.6.1/dune-2.6.1.tbz" 38 | checksum: [ 39 | "sha256=5ef959f286448ee172f1cffc86c439a6f7b662676e6015b282db071bb88899a0" 40 | "sha512=67b750716563fde1135f3d0f3892f97e912d6f95a40bcd7cd854f3ae09ba0b037e7b8829bdaee141cb6c998396f2a51a380451db117571d77895781798d625e7" 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /src/type-map/DigTypes.re: -------------------------------------------------------------------------------- 1 | open Migrate_parsetree.Ast_407; 2 | 3 | type shortReference = (string, list(string), string); 4 | 5 | type reference = { 6 | uri: string, 7 | moduleName: string, 8 | declared: SharedTypes.declared(SharedTypes.Type.t), 9 | modulePath: list(string), 10 | name: string, 11 | env: Query.queryEnv, 12 | }; 13 | 14 | let toShortReference = ({moduleName, modulePath, name}) => ( 15 | moduleName, 16 | modulePath, 17 | name, 18 | ); 19 | 20 | let showReference = ({moduleName, modulePath, name}) => { 21 | String.concat(".", [moduleName] @ modulePath @ [name]); 22 | }; 23 | 24 | let referenceToLident = ({moduleName, modulePath, name}) => { 25 | switch (Longident.unflatten([moduleName] @ modulePath @ [name])) { 26 | | None => assert(false) 27 | | Some(lident) => lident 28 | }; 29 | }; 30 | 31 | type typeSource('reference) = 32 | | Builtin(string) 33 | | Public('reference) 34 | | NotFound(string); 35 | 36 | let toShortSource = source => 37 | switch (source) { 38 | | Builtin(s) => Builtin(s) 39 | | NotFound(s) => NotFound(s) 40 | | Public(r) => Public(toShortReference(r)) 41 | }; 42 | 43 | type typeMap('reference) = 44 | Hashtbl.t( 45 | shortReference, 46 | ( 47 | Parsetree.attributes, 48 | SharedTypes.SimpleType.declaration(typeSource('reference)), 49 | ), 50 | ); 51 | 52 | type typeMap2 = Parsetree.attributes; 53 | -------------------------------------------------------------------------------- /esy.lock/opam/uri.3.1.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "anil@recoil.org" 3 | authors: ["Anil Madhavapeddy" "David Sheets" "Rudi Grinberg"] 4 | license: "ISC" 5 | tags: ["url" "uri" "org:mirage" "org:xapi-project"] 6 | homepage: "https://github.com/mirage/ocaml-uri" 7 | bug-reports: "https://github.com/mirage/ocaml-uri/issues" 8 | dev-repo: "git+https://github.com/mirage/ocaml-uri.git" 9 | doc: "https://mirage.github.io/ocaml-uri/" 10 | synopsis: "An RFC3986 URI/URL parsing library" 11 | description: """ 12 | This is an OCaml implementation of the [RFC3986](http://tools.ietf.org/html/rfc3986) specification 13 | for parsing URI or URLs. 14 | """ 15 | depends: [ 16 | "ocaml" {>= "4.04.0"} 17 | "dune" {>= "1.2.0"} 18 | "ounit" {with-test & >= "1.0.2"} 19 | "ppx_sexp_conv" {with-test & >= "v0.9.0" & < "v0.15"} 20 | "re" {>= "1.9.0"} 21 | "stringext" {>= "1.4.0"} 22 | ] 23 | build: [ 24 | ["dune" "subst"] {pinned} 25 | ["dune" "build" "-p" name "-j" jobs] 26 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 27 | ] 28 | url { 29 | src: 30 | "https://github.com/mirage/ocaml-uri/releases/download/v3.1.0/uri-v3.1.0.tbz" 31 | checksum: [ 32 | "sha256=c452823fd870cf7cffe51aef3e9ca646a382dc6f87282f2b16bfe30a7515ac43" 33 | "sha512=c015576bb077fd243022bcd8804e628d23a253dcd8bbdda8dc2a57e86cfeb9fd629087ec7d7e23dc71dd7cd137450ca2c5ecf8fb7d184ec9d1d4e41f6f83ee38" 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /esy.lock/opam/base.v0.14.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "opensource@janestreet.com" 3 | authors: ["Jane Street Group, LLC "] 4 | homepage: "https://github.com/janestreet/base" 5 | bug-reports: "https://github.com/janestreet/base/issues" 6 | dev-repo: "git+https://github.com/janestreet/base.git" 7 | doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/base/index.html" 8 | license: "MIT" 9 | build: [ 10 | ["dune" "build" "-p" name "-j" jobs] 11 | ] 12 | depends: [ 13 | "ocaml" {>= "4.07.0"} 14 | "sexplib0" {>= "v0.14" & < "v0.15"} 15 | "dune" {>= "2.0.0"} 16 | "dune-configurator" 17 | ] 18 | synopsis: "Full standard library replacement for OCaml" 19 | description: " 20 | Full standard library replacement for OCaml 21 | 22 | Base is a complete and portable alternative to the OCaml standard 23 | library. It provides all standard functionalities one would expect 24 | from a language standard library. It uses consistent conventions 25 | across all of its module. 26 | 27 | Base aims to be usable in any context. As a result system dependent 28 | features such as I/O are not offered by Base. They are instead 29 | provided by companion libraries such as stdio: 30 | 31 | https://github.com/janestreet/stdio 32 | " 33 | url { 34 | src: "https://ocaml.janestreet.com/ocaml-core/v0.14/files/base-v0.14.0.tar.gz" 35 | checksum: "md5=5a00382c724e97b6768aaa27481dd3cc" 36 | } 37 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/yojson.1.6.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "martin@mjambon.com" 3 | authors: ["Martin Jambon"] 4 | homepage: "https://github.com/ocaml-community/yojson" 5 | bug-reports: "https://github.com/ocaml-community/yojson/issues" 6 | dev-repo: "git+https://github.com/ocaml-community/yojson.git" 7 | doc: "https://ocaml-community.github.io/yojson/" 8 | build: [ 9 | ["dune" "subst"] {pinned} 10 | ["dune" "build" "-p" name "-j" jobs] 11 | ] 12 | run-test: [["dune" "runtest" "-p" name "-j" jobs]] 13 | depends: [ 14 | "ocaml" {>= "4.02.3"} 15 | "dune" {build} 16 | "cppo" {build} 17 | "easy-format" 18 | "biniou" {>= "1.2.0"} 19 | "alcotest" {with-test & >= "0.8.5"} 20 | ] 21 | synopsis: 22 | "Yojson is an optimized parsing and printing library for the JSON format" 23 | description: """ 24 | Yojson is an optimized parsing and printing library for the JSON format. 25 | 26 | It addresses a few shortcomings of json-wheel including 2x speedup, 27 | polymorphic variants and optional syntax for tuples and variants. 28 | 29 | ydump is a pretty-printing command-line program provided with the 30 | yojson package. 31 | 32 | The program atdgen can be used to derive OCaml-JSON serializers and 33 | deserializers from type definitions.""" 34 | url { 35 | src: 36 | "https://github.com/ocaml-community/yojson/releases/download/1.6.0/yojson-1.6.0.tbz" 37 | checksum: "md5=8ca16557d3068253cc375452af3bde96" 38 | } 39 | -------------------------------------------------------------------------------- /esy.lock/opam/dune-configurator.2.6.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | synopsis: "Helper library for gathering system configuration" 3 | description: """ 4 | dune-configurator is a small library that helps writing OCaml scripts that 5 | test features available on the system, in order to generate config.h 6 | files for instance. 7 | Among other things, dune-configurator allows one to: 8 | - test if a C program compiles 9 | - query pkg-config 10 | - import #define from OCaml header files 11 | - generate config.h file 12 | """ 13 | maintainer: ["Jane Street Group, LLC "] 14 | authors: ["Jane Street Group, LLC "] 15 | license: "MIT" 16 | homepage: "https://github.com/ocaml/dune" 17 | doc: "https://dune.readthedocs.io/" 18 | bug-reports: "https://github.com/ocaml/dune/issues" 19 | depends: [ 20 | "dune" {>= "2.6"} 21 | "dune-private-libs" {= version} 22 | ] 23 | dev-repo: "git+https://github.com/ocaml/dune.git" 24 | build: [ 25 | ["dune" "subst"] {pinned} 26 | [ 27 | "dune" 28 | "build" 29 | "-p" 30 | name 31 | "-j" 32 | jobs 33 | "@install" 34 | "@doc" {with-doc} 35 | ] 36 | ] 37 | url { 38 | src: "https://github.com/ocaml/dune/releases/download/2.6.1/dune-2.6.1.tbz" 39 | checksum: [ 40 | "sha256=5ef959f286448ee172f1cffc86c439a6f7b662676e6015b282db071bb88899a0" 41 | "sha512=67b750716563fde1135f3d0f3892f97e912d6f95a40bcd7cd854f3ae09ba0b037e7b8829bdaee141cb6c998396f2a51a380451db117571d77895781798d625e7" 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /esy.lock/opam/ocaml-migrate-parsetree.1.7.3/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "frederic.bour@lakaban.net" 3 | authors: [ 4 | "Frédéric Bour " 5 | "Jérémie Dimino " 6 | ] 7 | license: "LGPL-2.1 with OCaml linking exception" 8 | homepage: "https://github.com/ocaml-ppx/ocaml-migrate-parsetree" 9 | bug-reports: "https://github.com/ocaml-ppx/ocaml-migrate-parsetree/issues" 10 | dev-repo: "git+https://github.com/ocaml-ppx/ocaml-migrate-parsetree.git" 11 | doc: "https://ocaml-ppx.github.io/ocaml-migrate-parsetree/" 12 | tags: [ "syntax" "org:ocamllabs" ] 13 | build: [ 14 | ["dune" "build" "-p" name "-j" jobs] 15 | ] 16 | depends: [ 17 | "result" 18 | "ppx_derivers" 19 | "dune" {>= "1.9.0"} 20 | "ocaml" {>= "4.02.3" & < "4.12"} 21 | ] 22 | synopsis: "Convert OCaml parsetrees between different versions" 23 | description: """ 24 | Convert OCaml parsetrees between different versions 25 | 26 | This library converts parsetrees, outcometree and ast mappers between 27 | different OCaml versions. High-level functions help making PPX 28 | rewriters independent of a compiler version. 29 | """ 30 | url { 31 | src: 32 | "https://github.com/ocaml-ppx/ocaml-migrate-parsetree/releases/download/v1.7.3/ocaml-migrate-parsetree-v1.7.3.tbz" 33 | checksum: [ 34 | "sha256=6d85717bcf476b87f290714872ed4fbde0233dc899c3158a27f439d70224fb55" 35 | "sha512=fe9c74a244d160d973d8ca62e356edad4c872fc46471ddc668f854456d3979576895d446d49da2aee61c65b441b72c573225b0b254ab2eac4a0fb4debdbce9d4" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/tyxml.4.3.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "dev@ocsigen.org" 3 | homepage: "https://github.com/ocsigen/tyxml/" 4 | bug-reports: "https://github.com/ocsigen/tyxml/issues" 5 | doc: "https://ocsigen.org/tyxml/manual/" 6 | dev-repo: "git+https://github.com/ocsigen/tyxml.git" 7 | license: "LGPL-2.1 with OCaml linking exception" 8 | 9 | build: [ 10 | ["dune" "subst"] {pinned} 11 | ["dune" "build" "-p" name "-j" jobs] 12 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 13 | ] 14 | 15 | depends: [ 16 | "ocaml" {>= "4.02"} 17 | "dune" {build} 18 | "alcotest" {with-test} 19 | "seq" 20 | "uutf" {>= "1.0.0"} 21 | "re" {>= "1.5.0"} 22 | ] 23 | 24 | synopsis:"TyXML is a library for building correct HTML and SVG documents" 25 | description:""" 26 | TyXML provides a set of convenient combinators that uses the OCaml 27 | type system to ensure the validity of the generated documents. TyXML 28 | can be used with any representation of HTML and SVG: the textual one, 29 | provided directly by this package, or DOM trees (`js_of_ocaml-tyxml`) 30 | virtual DOM (`virtual-dom`) and reactive or replicated trees 31 | (`eliom`). You can also create your own representation and use it to 32 | instantiate a new set of combinators. 33 | 34 | ```ocaml 35 | open Tyxml 36 | let to_ocaml = Html.(a ~a:[a_href "ocaml.org"] [txt "OCaml!"]) 37 | ``` 38 | """ 39 | authors: "The ocsigen team" 40 | url { 41 | src: 42 | "https://github.com/ocsigen/tyxml/releases/download/4.3.0/tyxml-4.3.0.tbz" 43 | checksum: "md5=fd834a567f813bf447cab5f4c3a723e2" 44 | } 45 | -------------------------------------------------------------------------------- /esy.lock/opam/uutf.1.0.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://erratique.ch/software/uutf" 5 | doc: "http://erratique.ch/software/uutf/doc/Uutf" 6 | dev-repo: "git+http://erratique.ch/repos/uutf.git" 7 | bug-reports: "https://github.com/dbuenzli/uutf/issues" 8 | tags: [ "unicode" "text" "utf-8" "utf-16" "codec" "org:erratique" ] 9 | license: "ISC" 10 | depends: [ 11 | "ocaml" {>= "4.01.0"} 12 | "ocamlfind" {build} 13 | "ocamlbuild" {build} 14 | "topkg" {build} 15 | "uchar" 16 | ] 17 | depopts: ["cmdliner"] 18 | conflicts: ["cmdliner" { < "0.9.6"} ] 19 | build: [[ 20 | "ocaml" "pkg/pkg.ml" "build" 21 | "--pinned" "%{pinned}%" 22 | "--with-cmdliner" "%{cmdliner:installed}%" ]] 23 | synopsis: """Non-blocking streaming Unicode codec for OCaml""" 24 | description: """\ 25 | 26 | Uutf is a non-blocking streaming codec to decode and encode the UTF-8, 27 | UTF-16, UTF-16LE and UTF-16BE encoding schemes. It can efficiently 28 | work character by character without blocking on IO. Decoders perform 29 | character position tracking and support newline normalization. 30 | 31 | Functions are also provided to fold over the characters of UTF encoded 32 | OCaml string values and to directly encode characters in OCaml 33 | Buffer.t values. 34 | 35 | Uutf has no dependency and is distributed under the ISC license. 36 | """ 37 | url { 38 | archive: "http://erratique.ch/software/uutf/releases/uutf-1.0.2.tbz" 39 | checksum: "a7c542405a39630c689a82bd7ef2292c" 40 | } 41 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/astring.0.8.3/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://erratique.ch/software/astring" 5 | doc: "http://erratique.ch/software/astring/doc" 6 | dev-repo: "git+http://erratique.ch/repos/astring.git" 7 | bug-reports: "https://github.com/dbuenzli/astring/issues" 8 | tags: [ "string" "org:erratique" ] 9 | license: "ISC" 10 | depends: [ 11 | "ocaml" {>= "4.01.0"} 12 | "ocamlfind" {build} 13 | "ocamlbuild" {build} 14 | "topkg" {build} 15 | "base-bytes" 16 | ] 17 | build: [[ 18 | "ocaml" "pkg/pkg.ml" "build" 19 | "--pinned" "%{pinned}%" ]] 20 | synopsis: "Alternative String module for OCaml" 21 | description: """ 22 | Astring exposes an alternative `String` module for OCaml. This module 23 | tries to balance minimality and expressiveness for basic, index-free, 24 | string processing and provides types and functions for substrings, 25 | string sets and string maps. 26 | 27 | Remaining compatible with the OCaml `String` module is a non-goal. The 28 | `String` module exposed by Astring has exception safe functions, 29 | removes deprecated and rarely used functions, alters some signatures 30 | and names, adds a few missing functions and fully exploits OCaml's 31 | newfound string immutability. 32 | 33 | Astring depends only on the OCaml standard library. It is distributed 34 | under the ISC license.""" 35 | url { 36 | src: "http://erratique.ch/software/astring/releases/astring-0.8.3.tbz" 37 | checksum: "md5=c5bf6352b9ac27fbeab342740f4fa870" 38 | } 39 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/uutf.1.0.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://erratique.ch/software/uutf" 5 | doc: "http://erratique.ch/software/uutf/doc/Uutf" 6 | dev-repo: "git+http://erratique.ch/repos/uutf.git" 7 | bug-reports: "https://github.com/dbuenzli/uutf/issues" 8 | tags: [ "unicode" "text" "utf-8" "utf-16" "codec" "org:erratique" ] 9 | license: "ISC" 10 | depends: [ 11 | "ocaml" {>= "4.01.0"} 12 | "ocamlfind" {build} 13 | "ocamlbuild" {build} 14 | "topkg" {build} 15 | "uchar" 16 | ] 17 | depopts: ["cmdliner"] 18 | conflicts: ["cmdliner" { < "0.9.6"} ] 19 | build: [[ 20 | "ocaml" "pkg/pkg.ml" "build" 21 | "--pinned" "%{pinned}%" 22 | "--with-cmdliner" "%{cmdliner:installed}%" ]] 23 | synopsis: """Non-blocking streaming Unicode codec for OCaml""" 24 | description: """\ 25 | 26 | Uutf is a non-blocking streaming codec to decode and encode the UTF-8, 27 | UTF-16, UTF-16LE and UTF-16BE encoding schemes. It can efficiently 28 | work character by character without blocking on IO. Decoders perform 29 | character position tracking and support newline normalization. 30 | 31 | Functions are also provided to fold over the characters of UTF encoded 32 | OCaml string values and to directly encode characters in OCaml 33 | Buffer.t values. 34 | 35 | Uutf has no dependency and is distributed under the ISC license. 36 | """ 37 | url { 38 | archive: "http://erratique.ch/software/uutf/releases/uutf-1.0.2.tbz" 39 | checksum: "a7c542405a39630c689a82bd7ef2292c" 40 | } 41 | -------------------------------------------------------------------------------- /example/src/App.re: -------------------------------------------------------------------------------- 1 | /* stuff */ 2 | 3 | [@bs.module "fs"] external readFileSync: string => string = ""; 4 | [@bs.module "fs"] external writeFileSync: (string, string) => unit = ""; 5 | 6 | /* TODO check to see if a previous _version is parseable */ 7 | writeFileSync( 8 | "data." ++ Types.version ++ ".json", 9 | Js.Json.stringify(Serde.serializeHousehold(Types.example)), 10 | ); 11 | 12 | assert( 13 | Serde.deserializeHousehold(Serde.serializeHousehold(Types.example)) 14 | == Ok(Types.example), 15 | ); 16 | 17 | Types.all_versions->List.forEach(version => { 18 | let raw = readFileSync("data." ++ version ++ ".json"); 19 | let json = Js.Json.parseExn(raw); 20 | switch (Serde.deserializeHousehold(json)) { 21 | | Ok(result) => Js.log4(version, "Good", Js.Json.stringifyAny(result), Js.Json.stringify(json)) 22 | | Error(error) => Js.log3(version, "Failed", error) 23 | } 24 | }) 25 | 26 | /* 27 | This was just checking the quality of error messagse. 28 | 29 | let rawGood = [%bs.raw {| 30 | [6,{"people":[{"name":"Me","age":10,"coords":[5,6]}],"pets":[["Dog"],["Mouse"]],"visitors":[{ 31 | "name":"Friend","age":11.5,"coords":[1,6] 32 | }],"county":{"name":"Bearland","contents":5,"isClosed":false}}] 33 | |}]; 34 | 35 | let rawBad = [%bs.raw {| 36 | [6,{"people":[{"name":"Me","age":10,"coords":[5,6]}],"pets":[["Dog"],["Mouse"]],"visitors":[{ 37 | "name":"Friend","age":11.5,"coords":["hi",6] 38 | }],"county":{"name":"Bearland","contents":5,"isClosed":false}}] 39 | |}]; 40 | 41 | switch (Serde.deserializeHousehold(rawBad)) { 42 | | Ok(_) => assert(false) 43 | | Error(error) => Js.log2("Error message: ", Belt.List.toArray(error)) 44 | } */ 45 | -------------------------------------------------------------------------------- /types.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "schemaPropertyName": "milkSchemaVersion", 4 | "engines": { 5 | "rex-json": { 6 | "output": "src/type-map-serde/Serde.re", 7 | "helpers": "TransformHelpers" 8 | } 9 | }, 10 | "entries": [ 11 | { 12 | "file": "src/type-map-serde/Config.re", 13 | "type": "serializableLockfile" 14 | }, 15 | { 16 | "file": "src/type-map-serde/Config.re", 17 | "type": "t" 18 | }, 19 | { 20 | "file": "src/type-map-serde/Config.re", 21 | "type": "simpleDeclaration" 22 | }, 23 | { 24 | "file": "src/type-map-serde/Config.re", 25 | "type": "simpleExpr" 26 | } 27 | ], 28 | "custom": [ 29 | { 30 | "module": "Migrate_parsetree__Ast_407", 31 | "path": ["Parsetree"], 32 | "name": "signature" 33 | }, 34 | { 35 | "module": "Migrate_parsetree__Ast_407", 36 | "path": ["Parsetree"], 37 | "name": "structure" 38 | }, 39 | { 40 | "module": "Migrate_parsetree__Ast_407", 41 | "path": ["Parsetree"], 42 | "name": "core_type" 43 | }, 44 | { 45 | "module": "Migrate_parsetree__Ast_407", 46 | "path": ["Parsetree"], 47 | "name": "expression" 48 | }, 49 | { 50 | "module": "Migrate_parsetree__Ast_407", 51 | "path": ["Parsetree"], 52 | "name": "pattern" 53 | } 54 | ], 55 | "milkSchemaVersion": 1 56 | } 57 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/fmt.0.8.5/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: [ 4 | "Daniel Bünzli " 5 | "Gabriel Radanne" 6 | ] 7 | homepage: "http://erratique.ch/software/fmt" 8 | doc: "http://erratique.ch/software/fmt" 9 | dev-repo: "git+http://erratique.ch/repos/fmt.git" 10 | bug-reports: "https://github.com/dbuenzli/fmt/issues" 11 | tags: [ "string" "format" "pretty-print" "org:erratique" ] 12 | license: "ISC" 13 | depends: [ 14 | "ocaml" {>= "4.01.0"} 15 | "ocamlfind" {build} 16 | "ocamlbuild" {build} 17 | "topkg" {build & >= "0.9.0"} 18 | "result" 19 | "uchar" 20 | ] 21 | depopts: [ "base-unix" "cmdliner" ] 22 | conflicts: [ "cmdliner" {< "0.9.8"} ] 23 | build: [[ 24 | "ocaml" "pkg/pkg.ml" "build" 25 | "--dev-pkg" "%{pinned}%" 26 | "--with-base-unix" "%{base-unix:installed}%" 27 | "--with-cmdliner" "%{cmdliner:installed}%" ]] 28 | synopsis: "OCaml Format pretty-printer combinators" 29 | description: """ 30 | Fmt exposes combinators to devise `Format` pretty-printing functions. 31 | 32 | Fmt depends only on the OCaml standard library. The optional `Fmt_tty` 33 | library that allows to setup formatters for terminal color output 34 | depends on the Unix library. The optional `Fmt_cli` library that 35 | provides command line support for Fmt depends on [`Cmdliner`][cmdliner]. 36 | 37 | Fmt is distributed under the ISC license. 38 | 39 | [cmdliner]: http://erratique.ch/software/cmdliner""" 40 | url { 41 | src: "http://erratique.ch/software/fmt/releases/fmt-0.8.5.tbz" 42 | checksum: "md5=77b64aa6f20f09de28f2405d6195f12c" 43 | } 44 | -------------------------------------------------------------------------------- /example/for_codemodding/.ci/build-platform.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | platform: "macOS" 3 | vmImage: "macOS-10.13" 4 | STAGING_DIRECTORY: /Users/vsts/STAGING 5 | STAGING_DIRECTORY_UNIX: /Users/vsts/STAGING 6 | ESY__CACHE_INSTALL_PATH: /Users/vsts/.esy/3____________________________________________________________________/i 7 | ESY__CACHE_SOURCE_TARBALL_PATH: /Users/vsts/.esy/source/i 8 | 9 | jobs: 10 | - job: ${{ parameters.platform }} 11 | pool: 12 | vmImage: ${{ parameters.vmImage }} 13 | demands: node.js 14 | timeoutInMinutes: 120 # This is mostly for Windows 15 | variables: 16 | STAGING_DIRECTORY: ${{ parameters.STAGING_DIRECTORY }} 17 | STAGING_DIRECTORY_UNIX: ${{ parameters.STAGING_DIRECTORY_UNIX }} 18 | ESY__CACHE_INSTALL_PATH: ${{ parameters.ESY__CACHE_INSTALL_PATH }} 19 | ESY__CACHE_SOURCE_TARBALL_PATH: ${{ parameters.ESY__CACHE_SOURCE_TARBALL_PATH }} 20 | 21 | steps: 22 | - template: utils/use-node.yml 23 | - template: utils/use-esy.yml 24 | - template: utils/restore-build-cache.yml 25 | - script: "esy install" 26 | displayName: "esy install" 27 | - script: "esy build" 28 | displayName: "esy build" 29 | - template: utils/create-docs.yml 30 | - script: "esy test" 31 | displayName: "Test command" 32 | - script: "esy release" 33 | displayName: "esy release" 34 | - template: utils/publish-build-cache.yml 35 | - task: PublishBuildArtifacts@1 36 | displayName: "Publish Artifact: ${{ parameters.platform }}" 37 | inputs: 38 | PathtoPublish: "_release" 39 | ArtifactName: ${{ parameters.platform }} 40 | -------------------------------------------------------------------------------- /example/for_codemodding/azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | name: Build npm release 2 | 3 | trigger: 4 | - master 5 | 6 | jobs: 7 | - template: .ci/build-platform.yml 8 | parameters: 9 | platform: Linux 10 | vmImage: ubuntu-16.04 11 | STAGING_DIRECTORY: /home/vsts/STAGING 12 | STAGING_DIRECTORY_UNIX: /home/vsts/STAGING 13 | ESY__CACHE_INSTALL_PATH: /home/vsts/.esy/3_____________________________________________________________________/i 14 | ESY__CACHE_SOURCE_TARBALL_PATH: /home/vsts/.esy/source/i 15 | 16 | - template: .ci/build-platform.yml 17 | parameters: 18 | platform: macOS 19 | vmImage: macOS-10.13 20 | STAGING_DIRECTORY: /Users/vsts/STAGING 21 | STAGING_DIRECTORY_UNIX: /Users/vsts/STAGING 22 | ESY__CACHE_INSTALL_PATH: /Users/vsts/.esy/3____________________________________________________________________/i 23 | ESY__CACHE_SOURCE_TARBALL_PATH: /Users/vsts/.esy/source/i 24 | 25 | - template: .ci/build-platform.yml 26 | parameters: 27 | platform: Windows 28 | vmImage: vs2017-win2016 29 | STAGING_DIRECTORY: C:\Users\VssAdministrator\STAGING 30 | STAGING_DIRECTORY_UNIX: /C/Users/VssAdministrator/STAGING 31 | ESY__CACHE_INSTALL_PATH: /C/Users/VssAdministrator/.esy/3_/i 32 | ESY__CACHE_SOURCE_TARBALL_PATH: /C/Users/VssAdministrator/.esy/source/i 33 | 34 | # This job is kept here as we want to have the platform names in the same file 35 | - job: Release 36 | displayName: Release 37 | dependsOn: 38 | - Linux 39 | - macOS 40 | - Windows 41 | pool: 42 | vmImage: macOS-10.13 43 | demands: node.js 44 | steps: 45 | - template: .ci/cross-release.yml 46 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/cmdliner.1.0.3/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://erratique.ch/software/cmdliner" 5 | doc: "http://erratique.ch/software/cmdliner/doc/Cmdliner" 6 | dev-repo: "git+http://erratique.ch/repos/cmdliner.git" 7 | bug-reports: "https://github.com/dbuenzli/cmdliner/issues" 8 | tags: [ "cli" "system" "declarative" "org:erratique" ] 9 | license: "ISC" 10 | depends:[ "ocaml" {>= "4.03.0"} ] 11 | build: [[ make "all" "PREFIX=%{prefix}%" ]] 12 | install: 13 | [[make "install" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%" ] 14 | [make "install-doc" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%" ]] 15 | 16 | synopsis: """Declarative definition of command line interfaces for OCaml""" 17 | description: """\ 18 | 19 | Cmdliner allows the declarative definition of command line interfaces 20 | for OCaml. 21 | 22 | It provides a simple and compositional mechanism to convert command 23 | line arguments to OCaml values and pass them to your functions. The 24 | module automatically handles syntax errors, help messages and UNIX man 25 | page generation. It supports programs with single or multiple commands 26 | and respects most of the [POSIX][1] and [GNU][2] conventions. 27 | 28 | Cmdliner has no dependencies and is distributed under the ISC license. 29 | 30 | [1]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html 31 | [2]: http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html 32 | """ 33 | url { 34 | archive: "http://erratique.ch/software/cmdliner/releases/cmdliner-1.0.3.tbz" 35 | checksum: "3674ad01d4445424105d33818c78fba8" 36 | } 37 | -------------------------------------------------------------------------------- /esy.lock/opam/ocamlfind.1.8.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | synopsis: "A library manager for OCaml" 3 | maintainer: "Thomas Gazagnaire " 4 | authors: "Gerd Stolpmann " 5 | homepage: "http://projects.camlcity.org/projects/findlib.html" 6 | bug-reports: "https://gitlab.camlcity.org/gerd/lib-findlib/issues" 7 | dev-repo: "git+https://gitlab.camlcity.org/gerd/lib-findlib.git" 8 | description: """ 9 | Findlib is a library manager for OCaml. It provides a convention how 10 | to store libraries, and a file format ("META") to describe the 11 | properties of libraries. There is also a tool (ocamlfind) for 12 | interpreting the META files, so that it is very easy to use libraries 13 | in programs and scripts. 14 | """ 15 | build: [ 16 | [ 17 | "./configure" 18 | "-bindir" 19 | bin 20 | "-sitelib" 21 | lib 22 | "-mandir" 23 | man 24 | "-config" 25 | "%{lib}%/findlib.conf" 26 | "-no-custom" 27 | "-no-camlp4" {!ocaml:preinstalled & ocaml:version >= "4.02.0"} 28 | "-no-topfind" {ocaml:preinstalled} 29 | ] 30 | [make "all"] 31 | [make "opt"] {ocaml:native} 32 | ] 33 | install: [ 34 | [make "install"] 35 | ["install" "-m" "0755" "ocaml-stub" "%{bin}%/ocaml"] {ocaml:preinstalled} 36 | ] 37 | depends: [ 38 | "ocaml" {>= "4.00.0"} 39 | "conf-m4" {build} 40 | ] 41 | extra-files: [ 42 | ["ocamlfind.install" "md5=06f2c282ab52d93aa6adeeadd82a2543"] 43 | ["ocaml-stub" "md5=181f259c9e0bad9ef523e7d4abfdf87a"] 44 | ] 45 | url { 46 | src: "http://download.camlcity.org/download/findlib-1.8.1.tar.gz" 47 | checksum: "md5=18ca650982c15536616dea0e422cbd8c" 48 | mirrors: "http://download2.camlcity.org/download/findlib-1.8.1.tar.gz" 49 | } 50 | depopts: ["graphics"] 51 | -------------------------------------------------------------------------------- /esy.lock/opam/tyxml.4.4.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "dev@ocsigen.org" 3 | homepage: "https://github.com/ocsigen/tyxml/" 4 | bug-reports: "https://github.com/ocsigen/tyxml/issues" 5 | doc: "https://ocsigen.org/tyxml/manual/" 6 | dev-repo: "git+https://github.com/ocsigen/tyxml.git" 7 | license: "LGPL-2.1 with OCaml linking exception" 8 | 9 | build: [ 10 | ["dune" "subst"] {pinned} 11 | ["dune" "build" "-p" name "-j" jobs] 12 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 13 | ] 14 | 15 | depends: [ 16 | "ocaml" {>= "4.02"} 17 | "dune" 18 | "alcotest" {with-test} 19 | "seq" 20 | "uutf" {>= "1.0.0"} 21 | "re" {>= "1.5.0"} 22 | ] 23 | 24 | synopsis:"TyXML is a library for building correct HTML and SVG documents" 25 | description:""" 26 | TyXML provides a set of convenient combinators that uses the OCaml 27 | type system to ensure the validity of the generated documents. TyXML 28 | can be used with any representation of HTML and SVG: the textual one, 29 | provided directly by this package, or DOM trees (`js_of_ocaml-tyxml`) 30 | virtual DOM (`virtual-dom`) and reactive or replicated trees 31 | (`eliom`). You can also create your own representation and use it to 32 | instantiate a new set of combinators. 33 | 34 | ```ocaml 35 | open Tyxml 36 | let to_ocaml = Html.(a ~a:[a_href "ocaml.org"] [txt "OCaml!"]) 37 | ``` 38 | """ 39 | authors: "The ocsigen team" 40 | url { 41 | src: 42 | "https://github.com/ocsigen/tyxml/releases/download/4.4.0/tyxml-4.4.0.tbz" 43 | checksum: [ 44 | "sha256=516394dd4a5c31726997c51d66aa31cacb91e3c46d4e16c7699130e204042530" 45 | "sha512=d5f2187f8410524cec7a14b28e8950837070eb0b6571b015dd06076c2841eb7ccaffa86d5d2307eaf1950ee62f9fb926477dac01c870d9c1a2f525853cb44d0c" 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /example/for_codemodding/README.md: -------------------------------------------------------------------------------- 1 | # hello-reason 2 | 3 | [![Build Status](https://dev.azure.com/esy-ocaml/esy-ocaml/_apis/build/status/esy-ocaml.hello-reason?branchName=master)](https://dev.azure.com/esy-ocaml/esy-ocaml/_build/latest?definitionId=1?branchName=master) 4 | 5 | A project which demonstrates a Reason workflow with [Esy][]. 6 | 7 | [Esy]: https://github.com/esy-ocaml/esy 8 | 9 | 10 | ## Usage 11 | 12 | You need Esy, you can install the beta using [npm](https://npmjs.com): 13 | 14 | % npm install -g esy@latest 15 | 16 | > NOTE: Make sure `esy --version` returns at least `0.5.4` for this project to build. 17 | 18 | Then run the `esy` command from this project root to install and build depenencies. 19 | 20 | % esy 21 | 22 | Now you can run your editor within the environment (which also includes merlin): 23 | 24 | % esy $EDITOR 25 | % esy vim 26 | 27 | Alternatively you can try [vim-reasonml](https://github.com/jordwalke/vim-reasonml) 28 | which loads esy project environments automatically. 29 | 30 | After you make some changes to source code, you can re-run project's build 31 | again with the same simple `esy` command. 32 | 33 | % esy 34 | 35 | And test compiled executable (runs `scripts.tests` specified in 36 | `package.json`): 37 | 38 | % esy test 39 | 40 | Documentation for the libraries in the project can be generated with: 41 | 42 | % esy doc 43 | % esy open '#{self.target_dir}/default/_doc/_html/index.html' 44 | 45 | Shell into environment: 46 | 47 | % esy shell 48 | 49 | 50 | ## Create Prebuilt Release: 51 | 52 | `esy` allows creating prebuilt binary packages for your current platform, with 53 | no dependencies. 54 | 55 | % esy npm-release 56 | % cd _release 57 | % npm publish 58 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/bos.0.2.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://erratique.ch/software/bos" 5 | doc: "http://erratique.ch/software/bos/doc" 6 | dev-repo: "git+http://erratique.ch/repos/bos.git" 7 | bug-reports: "https://github.com/dbuenzli/bos/issues" 8 | tags: [ "os" "system" "cli" "command" "file" "path" "log" "unix" "org:erratique" ] 9 | license: "ISC" 10 | depends: [ 11 | "ocaml" {>= "4.01.0"} 12 | "ocamlfind" {build} 13 | "ocamlbuild" {build} 14 | "topkg" {build & >= "0.9.0"} 15 | "base-unix" 16 | "rresult" {>= "0.4.0"} 17 | "astring" 18 | "fpath" 19 | "fmt" {>= "0.8.0"} 20 | "logs" 21 | "mtime" {with-test} 22 | ] 23 | build: [[ 24 | "ocaml" "pkg/pkg.ml" "build" 25 | "--dev-pkg" "%{pinned}%" ]] 26 | synopsis: "Basic OS interaction for OCaml" 27 | description: """ 28 | Bos provides support for basic and robust interaction with the 29 | operating system in OCaml. It has functions to access the process 30 | environment, parse command line arguments, interact with the file 31 | system and run command line programs. 32 | 33 | Bos works equally well on POSIX and Windows operating systems. 34 | 35 | Bos depends on [Rresult][rresult], [Astring][astring], [Fmt][fmt], 36 | [Fpath][fpath] and [Logs][logs] and the OCaml Unix library. It is 37 | distributed under the ISC license. 38 | 39 | [rresult]: http://erratique.ch/software/rresult 40 | [astring]: http://erratique.ch/software/astring 41 | [fmt]: http://erratique.ch/software/fmt 42 | [fpath]: http://erratique.ch/software/fpath 43 | [logs]: http://erratique.ch/software/logs""" 44 | url { 45 | src: "http://erratique.ch/software/bos/releases/bos-0.2.0.tbz" 46 | checksum: "md5=aeae7447567db459c856ee41b5a66fd2" 47 | } 48 | -------------------------------------------------------------------------------- /esy.lock/opam/ptime.0.8.5/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["The ptime programmers"] 4 | homepage: "https://erratique.ch/software/ptime" 5 | doc: "https://erratique.ch/software/ptime/doc" 6 | dev-repo: "git+http://erratique.ch/repos/ptime.git" 7 | bug-reports: "https://github.com/dbuenzli/ptime/issues" 8 | tags: [ "time" "posix" "system" "org:erratique" ] 9 | license: "ISC" 10 | depends: [ 11 | "ocaml" {>= "4.01.0"} 12 | "ocamlfind" {build} 13 | "ocamlbuild" {build} 14 | "topkg" {build} 15 | "result" 16 | ] 17 | depopts: [ "js_of_ocaml" ] 18 | conflicts: [ "js_of_ocaml" { < "3.3.0" } ] 19 | build:[[ 20 | "ocaml" "pkg/pkg.ml" "build" 21 | "--pinned" "%{pinned}%" 22 | "--with-js_of_ocaml" "%{js_of_ocaml:installed}%" ]] 23 | 24 | synopsis: """POSIX time for OCaml""" 25 | description: """\ 26 | 27 | Ptime has platform independent POSIX time support in pure OCaml. It 28 | provides a type to represent a well-defined range of POSIX timestamps 29 | with picosecond precision, conversion with date-time values, 30 | conversion with [RFC 3339 timestamps][rfc3339] and pretty printing to a 31 | human-readable, locale-independent representation. 32 | 33 | The additional Ptime_clock library provides access to a system POSIX 34 | clock and to the system's current time zone offset. 35 | 36 | Ptime is not a calendar library. 37 | 38 | Ptime depends on the `result` compatibility package. Ptime_clock 39 | depends on your system library. Ptime_clock's optional JavaScript 40 | support depends on [js_of_ocaml][jsoo]. Ptime and its libraries are 41 | distributed under the ISC license. 42 | 43 | [rfc3339]: http://tools.ietf.org/html/rfc3339 44 | [jsoo]: http://ocsigen.org/js_of_ocaml/ 45 | """ 46 | url { 47 | archive: "https://erratique.ch/software/ptime/releases/ptime-0.8.5.tbz" 48 | checksum: "4d48055d623ecf2db792439b3e96a520" 49 | } 50 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/dune.1.6.3/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "opensource@janestreet.com" 3 | authors: ["Jane Street Group, LLC "] 4 | homepage: "https://github.com/ocaml/dune" 5 | bug-reports: "https://github.com/ocaml/dune/issues" 6 | dev-repo: "git+https://github.com/ocaml/dune.git" 7 | license: "MIT" 8 | depends: [ 9 | "ocaml" {>= "4.02"} 10 | "base-unix" 11 | "base-threads" 12 | ] 13 | build: [ 14 | # opam 2 sets OPAM_SWITCH_PREFIX, so we don't need a hardcoded path 15 | ["ocaml" "configure.ml" "--libdir" lib] {opam-version < "2"} 16 | ["ocaml" "bootstrap.ml"] 17 | ["./boot.exe" "--release" "--subst"] {pinned} 18 | ["./boot.exe" "--release" "-j" jobs] 19 | ] 20 | conflicts: [ 21 | "jbuilder" {!= "transition"} 22 | "odoc" {< "1.3.0"} 23 | ] 24 | 25 | synopsis: "Fast, portable and opinionated build system" 26 | description: """ 27 | dune is a build system that was designed to simplify the release of 28 | Jane Street packages. It reads metadata from "dune" files following a 29 | very simple s-expression syntax. 30 | 31 | dune is fast, it has very low-overhead and support parallel builds on 32 | all platforms. It has no system dependencies, all you need to build 33 | dune and packages using dune is OCaml. You don't need or make or bash 34 | as long as the packages themselves don't use bash explicitly. 35 | 36 | dune supports multi-package development by simply dropping multiple 37 | repositories into the same directory. 38 | 39 | It also supports multi-context builds, such as building against 40 | several opam roots/switches simultaneously. This helps maintaining 41 | packages across several versions of OCaml and gives cross-compilation 42 | for free. 43 | """ 44 | url { 45 | src: "https://github.com/ocaml/dune/releases/download/1.6.3/dune-1.6.3.tbz" 46 | checksum: "md5=1212a36547d25269675d767c38fecf5f" 47 | } 48 | -------------------------------------------------------------------------------- /.ci/restore-build-cache.yml: -------------------------------------------------------------------------------- 1 | # Steps for restoring project cache 2 | 3 | steps: 4 | - task: DownloadBuildArtifacts@0 5 | condition: succeeded() 6 | # condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) 7 | displayName: '[Cache][Restore] Restore install' 8 | inputs: 9 | buildType: 'specific' 10 | project: '$(System.TeamProject)' 11 | pipeline: '$(Build.DefinitionName)' 12 | branchName: 'refs/heads/master' 13 | buildVersionToDownload: 'latestFromBranch' 14 | downloadType: 'single' 15 | artifactName: 'cache-$(Agent.OS)-install' 16 | downloadPath: '$(STAGING_DIRECTORY)' 17 | continueOnError: true 18 | 19 | - bash: 'mkdir -p $(ESY__CACHE_INSTALL_PATH)' 20 | condition: succeeded() 21 | # condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) 22 | displayName: '[Cache][Restore] Create cache directory' 23 | 24 | # - bash: 'cd $(ESY__NPM_ROOT) && tar -xf $(STAGING_DIRECTORY_UNIX)/cache-$(Agent.OS)-install/npm-cache.tar -C .' 25 | # continueOnError: true 26 | # condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) 27 | # displayName: '[Cache][Restore] Untar npm cache directory' 28 | 29 | - bash: 'cd $(ESY__CACHE_INSTALL_PATH) && tar -xf $(STAGING_DIRECTORY_UNIX)/cache-$(Agent.OS)-install/esy-cache.tar -C .' 30 | continueOnError: true 31 | condition: succeeded() 32 | # condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) 33 | displayName: '[Cache][Restore] Untar esy cache directory' 34 | 35 | - bash: 'rm -rf *' 36 | continueOnError: true 37 | workingDirectory: '$(STAGING_DIRECTORY)' 38 | condition: succeeded() 39 | # condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) 40 | displayName: '[Cache][Restore] Clean up' 41 | -------------------------------------------------------------------------------- /src/type-map-serde/TypeMapSerde.re: -------------------------------------------------------------------------------- 1 | let lockfileToJson = Serde.serializeSerializableLockfile; 2 | let lockfileFromJson = Serde.deserializeSerializableLockfile; 3 | 4 | let configToJson = Serde.serializeT; 5 | let configFromJson = Serde.deserializeT; 6 | 7 | let checkVersion = (~upvert, ~configPath, config, json) => { 8 | let version = Serde.parseVersion(json); 9 | switch (version) { 10 | | Ok((version, _)) when version != Serde.currentVersion => 11 | if (upvert) { 12 | switch configPath { 13 | | `Nested(otherPath) => 14 | try { 15 | let json = Json.parse(Files.readFileExn(otherPath)); 16 | let json = switch json { 17 | | Json.Object(items) => 18 | let newConfig = configToJson(config); 19 | let rec loop = items => switch items { 20 | | [("milk", _), ...rest] => [("milk", newConfig), ...rest] 21 | | [one, ...rest] => [one, ...loop(rest)] 22 | | [] => failwith("milk section not found") 23 | }; 24 | loop(items) 25 | | _ => failwith("Invalid config") 26 | }; 27 | Util.Files.writeFileExn(otherPath, Vendor.Json.stringifyPretty(Json.Object(json))); 28 | } { 29 | | _ => print_endline("Failed to upvert your nested configuration in " ++ otherPath) 30 | }; 31 | // print_endline("Unable to upvert nested config just yet") 32 | | `Top(configPath) => 33 | Util.Files.writeFileExn(configPath, Vendor.Json.stringifyPretty(configToJson(config))); 34 | } 35 | } else { 36 | print_endline("Notice: You're using an outdated config schema. To upvert, pass --upvert."); 37 | } 38 | | _ => () 39 | }; 40 | }; 41 | 42 | let dumpExpr = Serde.serializeSimpleExpr; 43 | let dumpDecl = Serde.serializeSimpleDeclaration; 44 | let parseVersion = Serde.parseVersion; 45 | 46 | module Config = Config; -------------------------------------------------------------------------------- /esy.lock/opam/ppxlib.0.13.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "opensource@janestreet.com" 3 | authors: ["Jane Street Group, LLC "] 4 | homepage: "https://github.com/ocaml-ppx/ppxlib" 5 | bug-reports: "https://github.com/ocaml-ppx/ppxlib/issues" 6 | dev-repo: "git+https://github.com/ocaml-ppx/ppxlib.git" 7 | doc: "https://ocaml-ppx.github.io/ppxlib/" 8 | license: "MIT" 9 | build: [ 10 | ["dune" "subst"] {pinned} 11 | ["dune" "build" "-p" name "-j" jobs] 12 | ] 13 | run-test: [ 14 | ["dune" "runtest" "-p" name "-j" jobs] { ocaml:version >= "4.06" & ocaml:version < "4.08" } 15 | ] 16 | depends: [ 17 | "ocaml" {>= "4.04.1"} 18 | "base" {>= "v0.11.0"} 19 | "dune" 20 | "ocaml-compiler-libs" {>= "v0.11.0"} 21 | "ocaml-migrate-parsetree" {>= "1.3.1"} 22 | "ppx_derivers" {>= "1.0"} 23 | "stdio" {>= "v0.11.0"} 24 | "ocamlfind" {with-test} 25 | "cinaps" {with-test & >= "v0.12.1"} 26 | ] 27 | synopsis: "Base library and tools for ppx rewriters" 28 | description: """ 29 | A comprehensive toolbox for ppx development. It features: 30 | - a OCaml AST / parser / pretty-printer snapshot,to create a full 31 | frontend independent of the version of OCaml; 32 | - a library for library for ppx rewriters in general, and type-driven 33 | code generators in particular; 34 | - a feature-full driver for OCaml AST transformers; 35 | - a quotation mechanism allowing to write values representing the 36 | OCaml AST in the OCaml syntax; 37 | - a generator of open recursion classes from type definitions. 38 | """ 39 | url { 40 | src: 41 | "https://github.com/ocaml-ppx/ppxlib/releases/download/0.13.0/ppxlib-0.13.0.tbz" 42 | checksum: [ 43 | "sha256=81e1f3d308500e0e7f6108d5b0dda2b879640a5c21ef3dc4a9bd90381cee39d9" 44 | "sha512=c94bab35affdbdd2562de7ad30eb97282568c2c7fe48229fab5d12d1fc73312a9ee398758d598d969318cc01e8f88df9958e91820785e39d8faf3dbd7bc2e606" 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/ocamlfind.1.8.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Thomas Gazagnaire " 3 | homepage: "http://projects.camlcity.org/projects/findlib.html" 4 | bug-reports: "https://gitlab.camlcity.org/gerd/lib-findlib/issues" 5 | dev-repo: "git+https://gitlab.camlcity.org/gerd/lib-findlib.git" 6 | build: [ 7 | [ 8 | "./configure" 9 | "-bindir" 10 | bin 11 | "-sitelib" 12 | lib 13 | "-mandir" 14 | man 15 | "-config" 16 | "%{lib}%/findlib.conf" 17 | "-no-custom" 18 | "-no-topfind" {ocaml:preinstalled} 19 | ] 20 | [make "all"] 21 | [make "opt"] {ocaml:native} 22 | ] 23 | install: [ 24 | [make "install"] 25 | ["install" "-m" "0755" "ocaml-stub" "%{bin}%/ocaml"] {ocaml:preinstalled} 26 | ] 27 | remove: [ 28 | ["ocamlfind" "remove" "bytes"] 29 | [ 30 | "./configure" 31 | "-bindir" 32 | bin 33 | "-sitelib" 34 | lib 35 | "-mandir" 36 | man 37 | "-config" 38 | "%{lib}%/findlib.conf" 39 | "-no-topfind" {ocaml:preinstalled} 40 | ] 41 | [make "uninstall"] 42 | ["rm" "-f" "%{bin}%/ocaml"] {ocaml:preinstalled} 43 | ] 44 | depends: [ 45 | "ocaml" {>= "4.00.0"} 46 | "conf-m4" {build} 47 | ] 48 | synopsis: "A library manager for OCaml" 49 | description: """ 50 | Findlib is a library manager for OCaml. It provides a convention how 51 | to store libraries, and a file format ("META") to describe the 52 | properties of libraries. There is also a tool (ocamlfind) for 53 | interpreting the META files, so that it is very easy to use libraries 54 | in programs and scripts.""" 55 | authors: "Gerd Stolpmann " 56 | extra-files: [ 57 | ["ocamlfind.install" "md5=06f2c282ab52d93aa6adeeadd82a2543"] 58 | ["ocaml-stub" "md5=181f259c9e0bad9ef523e7d4abfdf87a"] 59 | ] 60 | url { 61 | src: "http://download.camlcity.org/download/findlib-1.8.0.tar.gz" 62 | checksum: "md5=a710c559667672077a93d34eb6a42e5b" 63 | mirrors: "http://download2.camlcity.org/download/findlib-1.8.0.tar.gz" 64 | } 65 | -------------------------------------------------------------------------------- /esy.lock/opam/topkg.1.0.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://erratique.ch/software/topkg" 5 | doc: "http://erratique.ch/software/topkg/doc" 6 | license: "ISC" 7 | dev-repo: "git+http://erratique.ch/repos/topkg.git" 8 | bug-reports: "https://github.com/dbuenzli/topkg/issues" 9 | tags: ["packaging" "ocamlbuild" "org:erratique"] 10 | depends: [ 11 | "ocaml" {>= "4.03.0"} 12 | "ocamlfind" {build & >= "1.6.1"} 13 | "ocamlbuild" ] 14 | build: [[ 15 | "ocaml" "pkg/pkg.ml" "build" 16 | "--pkg-name" name 17 | "--dev-pkg" "%{pinned}%" ]] 18 | synopsis: """The transitory OCaml software packager""" 19 | description: """\ 20 | 21 | Topkg is a packager for distributing OCaml software. It provides an 22 | API to describe the files a package installs in a given build 23 | configuration and to specify information about the package's 24 | distribution, creation and publication procedures. 25 | 26 | The optional topkg-care package provides the `topkg` command line tool 27 | which helps with various aspects of a package's life cycle: creating 28 | and linting a distribution, releasing it on the WWW, publish its 29 | documentation, add it to the OCaml opam repository, etc. 30 | 31 | Topkg is distributed under the ISC license and has **no** 32 | dependencies. This is what your packages will need as a *build* 33 | dependency. 34 | 35 | Topkg-care is distributed under the ISC license it depends on 36 | [fmt][fmt], [logs][logs], [bos][bos], [cmdliner][cmdliner], 37 | [webbrowser][webbrowser] and `opam-format`. 38 | 39 | [fmt]: http://erratique.ch/software/fmt 40 | [logs]: http://erratique.ch/software/logs 41 | [bos]: http://erratique.ch/software/bos 42 | [cmdliner]: http://erratique.ch/software/cmdliner 43 | [webbrowser]: http://erratique.ch/software/webbrowser 44 | """ 45 | url { 46 | archive: "http://erratique.ch/software/topkg/releases/topkg-1.0.1.tbz" 47 | checksum: "16b90e066d8972a5ef59655e7c28b3e9" 48 | } 49 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/topkg.1.0.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://erratique.ch/software/topkg" 5 | doc: "http://erratique.ch/software/topkg/doc" 6 | license: "ISC" 7 | dev-repo: "git+http://erratique.ch/repos/topkg.git" 8 | bug-reports: "https://github.com/dbuenzli/topkg/issues" 9 | tags: ["packaging" "ocamlbuild" "org:erratique"] 10 | depends: [ 11 | "ocaml" {>= "4.01.0"} 12 | "ocamlfind" {build & >= "1.6.1"} 13 | "ocamlbuild" 14 | "result" ] 15 | build: [[ 16 | "ocaml" "pkg/pkg.ml" "build" 17 | "--pkg-name" name 18 | "--dev-pkg" "%{pinned}%" ]] 19 | synopsis: """The transitory OCaml software packager""" 20 | description: """\ 21 | 22 | Topkg is a packager for distributing OCaml software. It provides an 23 | API to describe the files a package installs in a given build 24 | configuration and to specify information about the package's 25 | distribution, creation and publication procedures. 26 | 27 | The optional topkg-care package provides the `topkg` command line tool 28 | which helps with various aspects of a package's life cycle: creating 29 | and linting a distribution, releasing it on the WWW, publish its 30 | documentation, add it to the OCaml opam repository, etc. 31 | 32 | Topkg is distributed under the ISC license and has **no** 33 | dependencies. This is what your packages will need as a *build* 34 | dependency. 35 | 36 | Topkg-care is distributed under the ISC license it depends on 37 | [fmt][fmt], [logs][logs], [bos][bos], [cmdliner][cmdliner], 38 | [webbrowser][webbrowser] and `opam-format`. 39 | 40 | [fmt]: http://erratique.ch/software/fmt 41 | [logs]: http://erratique.ch/software/logs 42 | [bos]: http://erratique.ch/software/bos 43 | [cmdliner]: http://erratique.ch/software/cmdliner 44 | [webbrowser]: http://erratique.ch/software/webbrowser 45 | """ 46 | url { 47 | src: "http://erratique.ch/software/topkg/releases/topkg-1.0.0.tbz" 48 | checksum: "md5=e3d76bda06bf68cb5853caf6627da603" 49 | } 50 | -------------------------------------------------------------------------------- /example/run_all.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | const fs = require('fs') 3 | const path = require('path') 4 | const {spawnSync} = require('child_process') 5 | 6 | const allTypesRaw = fs.readFileSync(__dirname + '/src/AllTypes.re', 'utf8') 7 | const versions = allTypesRaw.split('\n').filter(line => line.match(/^module V\d+/)) 8 | .map(line => { 9 | const [_, major, __, minor] = line.match(/^module V(\d+)(_(\d+))?/); 10 | return {major: parseInt(major), minor: parseInt(minor)} 11 | }) 12 | 13 | const typesJson = __dirname + '/types.json' 14 | const typesLock = __dirname + '/types.lock.json' 15 | 16 | const config = { 17 | "//": "AUTOGENERATED by run_all.js", 18 | "version": 6, 19 | "$schemaVersion": 2, 20 | "engines": { 21 | "Js.Json": { 22 | "output": "src/Serde.re" 23 | } 24 | }, 25 | "entries": [ 26 | { 27 | "file": "src/Types.re", 28 | "type": "household" 29 | } 30 | ], 31 | "custom": [] 32 | } 33 | 34 | const asFull = ({major, minor}) => major + (minor ? '_' + minor : ''); 35 | 36 | const runVersion = (version, allVersions) => { 37 | let full = asFull(version) 38 | console.log('For version', full) 39 | fs.writeFileSync( 40 | __dirname + '/src/Types.re', 41 | `include AllTypes.V${full}; let version = "${full}"; let all_versions = [${ 42 | allVersions.map(version => `"${asFull(version)}"`).join(', ') 43 | }]` 44 | ) 45 | fs.writeFileSync(typesJson, JSON.stringify({...config, version: version.major}, null, 2)) 46 | } 47 | 48 | const run = (cmd, args) => { 49 | const result = spawnSync(cmd, args, { 50 | stdio: 'inherit', 51 | cwd: __dirname, 52 | }) 53 | if (result.status !== 0) { 54 | console.log(`Error running ${cmd} ${args.join(' ')}. Aborting`) 55 | process.exit(result.status) 56 | } 57 | }; 58 | 59 | run('rm', ['-f', 'types.lock.json']) 60 | const old_data = fs.readdirSync(__dirname).filter(name => name.match(/^data\..*\.json$/)) 61 | if (old_data.length) { 62 | run('rm', ['-f'].concat(old_data)) 63 | } 64 | 65 | versions.forEach((version, i) => { 66 | runVersion(version, versions.slice(0, i + 1)); 67 | run('npm', ['start', '-s']) 68 | run('rm', ['-rf', 'lib']) 69 | run('npm', ['run', '-s', 'try']) 70 | }) -------------------------------------------------------------------------------- /example/for_codemodding/.ci/pipelines-release.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const path = require("path"); 3 | 4 | console.log("Creating package.json"); 5 | const mainPackageJson = require("../package.json"); 6 | const packageJson = JSON.stringify( 7 | { 8 | name: mainPackageJson.name, 9 | version: mainPackageJson.version, 10 | license: mainPackageJson.license, 11 | description: mainPackageJson.description, 12 | repository: mainPackageJson.repository, 13 | scripts: { 14 | postinstall: "node ./postinstall.js" 15 | }, 16 | bin: mainPackageJson.esy.release.bin.reduce((acc, curr) => { 17 | return Object.assign({ [curr]: "bin/" + curr }, acc); 18 | }, {}), 19 | files: [ 20 | "_export/", 21 | "bin/", 22 | "postinstall.js", 23 | "esyInstallRelease.js", 24 | "platform-linux/", 25 | "platform-darwin/", 26 | "platform-windows-x64/" 27 | ] 28 | }, 29 | null, 30 | 2 31 | ); 32 | 33 | fs.writeFileSync( 34 | path.join(__dirname, "..", "_release", "package.json"), 35 | packageJson, 36 | { 37 | encoding: "utf8" 38 | } 39 | ); 40 | 41 | try { 42 | console.log("Copying LICENSE"); 43 | fs.copyFileSync( 44 | path.join(__dirname, "..", "LICENSE"), 45 | path.join(__dirname, "..", "_release", "LICENSE") 46 | ); 47 | } catch (e) { 48 | console.warn("No LICENSE found"); 49 | } 50 | 51 | console.log("Copying README.md"); 52 | fs.copyFileSync( 53 | path.join(__dirname, "..", "README.md"), 54 | path.join(__dirname, "..", "_release", "README.md") 55 | ); 56 | 57 | console.log("Copying postinstall.js"); 58 | fs.copyFileSync( 59 | path.join(__dirname, "release-postinstall.js"), 60 | path.join(__dirname, "..", "_release", "postinstall.js") 61 | ); 62 | 63 | console.log("Creating placeholder files"); 64 | const placeholderFile = `:; echo "You need to have postinstall enabled"; exit $? 65 | @ECHO OFF 66 | ECHO You need to have postinstall enabled`; 67 | fs.mkdirSync(path.join(__dirname, "..", "_release", "bin")); 68 | const binPath = path.join( 69 | __dirname, 70 | "..", 71 | "_release", 72 | "bin", 73 | mainPackageJson.esy.release.bin[0] 74 | ); 75 | 76 | fs.writeFileSync(binPath, placeholderFile); 77 | fs.chmodSync(binPath, 0777); 78 | -------------------------------------------------------------------------------- /codemod-example/ExampleCodemod.re: -------------------------------------------------------------------------------- 1 | open Migrate_parsetree.Ast_407; 2 | open Parsetree; 3 | 4 | open Codemod.Helpers; 5 | Printexc.record_backtrace(true); 6 | // Util.Log.spamError := true; 7 | // References.debugReferences := true; 8 | // MerlinFile.debug := true; 9 | print_endline("Spamming error"); 10 | 11 | /* 12 | 13 | "Convert all Error(x) to Error(Unspecified(x)) if the function's return type is Belt.Result.t(int, string)" 14 | 15 | */ 16 | 17 | let replaceErrors = (ctx, expr) => 18 | expr 19 | ->mapExpr((_mapper, expr) => { 20 | switch (expr.pexp_desc) { 21 | /* We should be more flexible here, e.g. to accept Result.Error() in addition to Error() */ 22 | | Pexp_construct({txt: Longident.Lident("Error")}, Some({pexp_desc: Pexp_tuple([arg])})) => 23 | switch (ctx->getExprType(arg)) { 24 | | Reference(Builtin("string"), []) => Some([%expr Error(Unspecified([%e arg]))]) 25 | | _ => None 26 | } 27 | | _ => None 28 | }; 29 | }); 30 | 31 | let modify = (ctx, structure) => { 32 | print_endline("ok"); 33 | structure->strExpr((_mapper, expr) => 34 | expr->mapFnExpr((_mapper, args, body) => { 35 | switch (ctx->getExprType(body)) { 36 | /* The type Belt.Result.t is just an alias for Belt_Result.t, and we have to specify the "original declaration" path */ 37 | | Reference(Public({moduleName: "Lib__Util", modulePath: ["Belt_Result"], name: "t"}), [Reference(Builtin("int"), []), Reference(Builtin("string"), [])]) => 38 | Some((args, ctx->replaceErrors(body))) 39 | // | Reference(Public({moduleName: something, modulePath: ["Belt_Result"], name: "t"}), [Reference(Builtin("int"), []), Reference(Builtin("string"), [])]) => 40 | // print_endline(something); 41 | // None 42 | | _ => 43 | None 44 | }; 45 | }) 46 | ->Some 47 | ); 48 | }; 49 | 50 | switch (Sys.argv) { 51 | | [|_, root|] => 52 | print_endline("Running on project: " ++ root); 53 | Codemod.run( 54 | ~rootPath=root, 55 | ~filterPath=(path, _moduleName) => 56 | // Str.string_match( 57 | // Str.regexp(".*/Example.re$"), 58 | // path, 59 | // 0 60 | // ), 61 | Filename.extension(path) == ".re", 62 | modify 63 | ); 64 | | _ => () 65 | }; 66 | -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/logs.0.6.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://erratique.ch/software/logs" 5 | doc: "http://erratique.ch/software/logs/doc" 6 | dev-repo: "git+http://erratique.ch/repos/logs.git" 7 | bug-reports: "https://github.com/dbuenzli/logs/issues" 8 | tags: [ "log" "system" "org:erratique" ] 9 | license: "ISC" 10 | depends: [ 11 | "ocaml" {>= "4.01.0"} 12 | "ocamlfind" {build} 13 | "ocamlbuild" {build} 14 | "topkg" {build} 15 | "result" 16 | "mtime" {with-test} 17 | ] 18 | depopts: [ 19 | "js_of_ocaml" 20 | "fmt" 21 | "cmdliner" 22 | "lwt" ] 23 | conflicts: [ "cmdliner" {< "0.9.8"} ] 24 | build: [[ 25 | "ocaml" "pkg/pkg.ml" "build" 26 | "--pinned" "%{pinned}%" 27 | "--with-js_of_ocaml" "%{js_of_ocaml:installed}%" 28 | "--with-fmt" "%{fmt:installed}%" 29 | "--with-cmdliner" "%{cmdliner:installed}%" 30 | "--with-lwt" "%{lwt:installed}%" ]] 31 | synopsis: "Logging infrastructure for OCaml" 32 | description: """ 33 | Logs provides a logging infrastructure for OCaml. Logging is performed 34 | on sources whose reporting level can be set independently. Log message 35 | report is decoupled from logging and is handled by a reporter. 36 | 37 | A few optional log reporters are distributed with the base library and 38 | the API easily allows to implement your own. 39 | 40 | `Logs` depends only on the `result` compatibility package. The 41 | optional `Logs_fmt` reporter on OCaml formatters depends on [Fmt][fmt]. 42 | The optional `Logs_browser` reporter that reports to the web browser 43 | console depends on [js_of_ocaml][jsoo]. The optional `Logs_cli` library 44 | that provides command line support for controlling Logs depends on 45 | [`Cmdliner`][cmdliner]. The optional `Logs_lwt` library that provides Lwt logging 46 | functions depends on [`Lwt`][lwt] 47 | 48 | Logs and its reporters are distributed under the ISC license. 49 | 50 | [fmt]: http://erratique.ch/software/fmt 51 | [jsoo]: http://ocsigen.org/js_of_ocaml/ 52 | [cmdliner]: http://erratique.ch/software/cmdliner 53 | [lwt]: http://ocsigen.org/lwt/""" 54 | url { 55 | src: "http://erratique.ch/software/logs/releases/logs-0.6.2.tbz" 56 | checksum: "md5=19f824c02c83c6dddc3bfb6459e4743e" 57 | } 58 | -------------------------------------------------------------------------------- /esy.lock/opam/dune.2.6.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | synopsis: "Fast, portable, and opinionated build system" 3 | description: """ 4 | 5 | dune is a build system that was designed to simplify the release of 6 | Jane Street packages. It reads metadata from "dune" files following a 7 | very simple s-expression syntax. 8 | 9 | dune is fast, has very low-overhead, and supports parallel builds on 10 | all platforms. It has no system dependencies; all you need to build 11 | dune or packages using dune is OCaml. You don't need make or bash 12 | as long as the packages themselves don't use bash explicitly. 13 | 14 | dune supports multi-package development by simply dropping multiple 15 | repositories into the same directory. 16 | 17 | It also supports multi-context builds, such as building against 18 | several opam roots/switches simultaneously. This helps maintaining 19 | packages across several versions of OCaml and gives cross-compilation 20 | for free. 21 | """ 22 | maintainer: ["Jane Street Group, LLC "] 23 | authors: ["Jane Street Group, LLC "] 24 | license: "MIT" 25 | homepage: "https://github.com/ocaml/dune" 26 | doc: "https://dune.readthedocs.io/" 27 | bug-reports: "https://github.com/ocaml/dune/issues" 28 | conflicts: [ 29 | "dune-configurator" {< "2.3.0"} 30 | "odoc" {< "1.3.0"} 31 | "dune-release" {< "1.3.0"} 32 | "js_of_ocaml-compiler" {< "3.6.0"} 33 | "jbuilder" {= "transition"} 34 | ] 35 | dev-repo: "git+https://github.com/ocaml/dune.git" 36 | build: [ 37 | # opam 2 sets OPAM_SWITCH_PREFIX, so we don't need a hardcoded path 38 | ["ocaml" "configure.ml" "--libdir" lib] {opam-version < "2"} 39 | ["ocaml" "bootstrap.ml" "-j" jobs] 40 | ["./dune.exe" "build" "-p" name "--profile" "dune-bootstrap" "-j" jobs] 41 | ] 42 | depends: [ 43 | # Please keep the lower bound in sync with .travis.yml, dune-project 44 | # and min_ocaml_version in bootstrap.ml 45 | ("ocaml" {>= "4.07"} | ("ocaml" {< "4.07~~"} & "ocamlfind-secondary")) 46 | "base-unix" 47 | "base-threads" 48 | ] 49 | url { 50 | src: "https://github.com/ocaml/dune/releases/download/2.6.1/dune-2.6.1.tbz" 51 | checksum: [ 52 | "sha256=5ef959f286448ee172f1cffc86c439a6f7b662676e6015b282db071bb88899a0" 53 | "sha512=67b750716563fde1135f3d0f3892f97e912d6f95a40bcd7cd854f3ae09ba0b037e7b8829bdaee141cb6c998396f2a51a380451db117571d77895781798d625e7" 54 | ] 55 | } 56 | -------------------------------------------------------------------------------- /src/serde/JsonCore.re: -------------------------------------------------------------------------------- 1 | 2 | 3 | open Migrate_parsetree.Ast_407; 4 | open Parsetree; 5 | let loc = Location.none; 6 | 7 | // TODO: use these at all 8 | module Deserialize = { 9 | 10 | let listExn = [%expr 11 | { 12 | let rec loop = (items) => switch items { 13 | | [] => [] 14 | | [one, ...rest] => [transformer(one), ...loop(rest)] 15 | }; 16 | Belt.List.toArray(loop(items)) 17 | } 18 | ]; 19 | 20 | let listTailExn = [%expr 21 | { 22 | let rec loop = (items, collected) => switch items { 23 | | [] => Belt.List.reverse(collected) 24 | | [one, ...rest] => loop(rest, [transformer(one), ...collected]) 25 | }; 26 | Belt.List.toArray(Belt.List.reverse(loop(items, []))) 27 | } 28 | ]; 29 | 30 | // let listTrackExn = [%expr 31 | // { 32 | // let rec loop = (i, items) => switch items { 33 | // | [] => [] 34 | // | [one, ...rest] => [transformer(["array item " ++ string_of_int(i), ...crumbs], one), ...loop(i + 1, rest)] 35 | // }; 36 | // Belt.List.toArray(loop(0, items)) 37 | // } 38 | // ]; 39 | 40 | let list = [%expr 41 | { 42 | let rec loop = (i, items) => switch items { 43 | | [] => Belt.Result.Ok([]) 44 | | [one, ...rest] => switch (transformer(one)) { 45 | | Belt.Result.Error(error) => Belt.Result.Error(["array element " ++ string_of_int(i), ...error]) 46 | | Belt.Result.Ok(value) => switch (loop(i + 1, rest)) { 47 | | Belt.Result.Error(error) => Belt.Result.Error(error) 48 | | Ok(rest) => Belt.Result.Ok([value, ...rest]) 49 | } 50 | } 51 | }; 52 | switch (loop(0, [], items)) { 53 | | Belt.Result.Error(error) => Belt.Result.Error(error) 54 | | Belt.Result.Ok(value) => Belt.Result.Ok(Belt.List.toArray(value)) 55 | } 56 | } 57 | ]; 58 | 59 | let listTailRecursive = [%expr 60 | { 61 | let rec loop = (i, collected, items) => switch items { 62 | | [] => Belt.Result.Ok(Belt.List.reverse(collected)) 63 | | [one, ...rest] => switch (transformer(one)) { 64 | | Belt.Result.Error(error) => Belt.Result.Error(["array element", ...error]) 65 | | Belt.Result.Ok(value) => loop(i + 1, [value, ...collected], rest) 66 | } 67 | }; 68 | switch (loop(0, [], items)) { 69 | | Belt.Result.Error(error) => Belt.Result.Error(error) 70 | | Belt.Result.Ok(value) => Belt.Result.Ok(Belt.List.toArray(value)) 71 | } 72 | } 73 | ]; 74 | 75 | } -------------------------------------------------------------------------------- /src/TypesFile.re: -------------------------------------------------------------------------------- 1 | open Migrate_parsetree.Ast_407; 2 | open DigUtils; 3 | 4 | let lockTypes = (~currentVersion, version, typeMap, lockedDeep) => { 5 | hashList(typeMap) 6 | ->Belt.List.sort(compare) 7 | ->Belt.List.map((((moduleName, modulePath, name) as ref, (_attributes, decl))) => { 8 | let alias = 9 | if (currentVersion == version 10 | || lockedDeep[currentVersion]->Upgrade.hashFind(ref) 11 | == lockedDeep[version]->Upgrade.hashFind(ref)) { 12 | Some(Serde.OutputType.unflatten([moduleName] @ modulePath @ [name])); 13 | } else if (version > 1 14 | && lockedDeep[version - 1]->Upgrade.hashFind(ref) 15 | == lockedDeep[version]->Upgrade.hashFind(ref)) { 16 | Some( 17 | Ldot( 18 | Lident(typesModuleName(version - 1)), 19 | Serde.OutputType.makeLockedTypeName(moduleName, modulePath, name), 20 | ), 21 | ); 22 | } else { 23 | None; 24 | }; 25 | Serde.OutputType.outputDeclaration( 26 | ~alias, 27 | moduleName, 28 | modulePath, 29 | name, 30 | Serde.OutputType.showSource, 31 | decl, 32 | ); 33 | }); 34 | }; 35 | 36 | let makeModule = (~currentVersion, ~lockedDeep, ~lockfile, version, typeMap) => { 37 | makeModule( 38 | typesModuleName(version), 39 | [ 40 | Ast_helper.Str.type_(Recursive, lockTypes(~currentVersion, version, typeMap, lockedDeep)), 41 | ...if (version > 1) { 42 | let pastTypeMap = lockfile->TypeMapSerde.Config.Locked.getVersion(version - 1).typeMap; 43 | [ 44 | Ast_helper.Str.value( 45 | Recursive, 46 | hashList(typeMap) 47 | ->Belt.List.sort(compare) 48 | ->Belt.List.keepMap((((moduleName, modulePath, name) as ref, decl)) => 49 | switch (pastTypeMap->Upgrade.hashFind(ref)) { 50 | | Some(dPast) => 51 | Some( 52 | Upgrade.makeUpgrader( 53 | version, 54 | pastTypeMap, 55 | lockedDeep, 56 | ~moduleName, 57 | ~modulePath, 58 | ~name, 59 | decl, 60 | dPast, 61 | ), 62 | ) 63 | | None => None 64 | } 65 | ), 66 | ), 67 | ]; 68 | } else { 69 | []; 70 | }, 71 | ], 72 | ); 73 | }; -------------------------------------------------------------------------------- /example/for_codemodding/esy.lock/opam/merlin.3.2.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | name: "merlin" 3 | synopsis: "Installation with Opam" 4 | description: """ 5 | If you have a working [Opam](https://opam.ocaml.org/) installation, Merlin is only two commands away: 6 | 7 | ```shell 8 | opam install merlin 9 | opam user-setup install 10 | ``` 11 | 12 | [opam-user-setup](https://github.com/OCamlPro/opam-user-setup) takes care of configuring Emacs and Vim to make best use of your current install. 13 | 14 | You can also [configure the editor](#editor-setup) yourself, if you prefer.""" 15 | maintainer: "defree@gmail.com" 16 | authors: "The Merlin team" 17 | homepage: "https://github.com/ocaml/merlin" 18 | bug-reports: "https://github.com/ocaml/merlin/issues" 19 | depends: [ 20 | "ocaml" {>= "4.02.1" & < "4.08"} 21 | "dune" {build} 22 | "ocamlfind" {>= "1.5.2"} 23 | "yojson" 24 | "craml" {with-test} 25 | ] 26 | build: [ 27 | ["dune" "subst"] {pinned} 28 | ["dune" "build" "-p" name "-j" jobs] 29 | ] 30 | post-messages: 31 | """ 32 | merlin installed. 33 | 34 | Quick setup for VIM 35 | ------------------- 36 | Append this to your .vimrc to add merlin to vim's runtime-path: 37 | let g:opamshare = substitute(system('opam config var share'),'\\n$','','''') 38 | execute "set rtp+=" . g:opamshare . "/merlin/vim" 39 | 40 | Also run the following line in vim to index the documentation: 41 | :execute "helptags " . g:opamshare . "/merlin/vim/doc" 42 | 43 | Quick setup for EMACS 44 | ------------------- 45 | Add opam emacs directory to your load-path by appending this to your .emacs: 46 | (let ((opam-share (ignore-errors (car (process-lines "opam" "config" "var" "share"))))) 47 | (when (and opam-share (file-directory-p opam-share)) 48 | ;; Register Merlin 49 | (add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share)) 50 | (autoload 'merlin-mode "merlin" nil t nil) 51 | ;; Automatically start it in OCaml buffers 52 | (add-hook 'tuareg-mode-hook 'merlin-mode t) 53 | (add-hook 'caml-mode-hook 'merlin-mode t) 54 | ;; Use opam switch to lookup ocamlmerlin binary 55 | (setq merlin-command 'opam))) 56 | 57 | Take a look at https://github.com/ocaml/merlin for more information 58 | 59 | Quick setup with opam-user-setup 60 | -------------------------------- 61 | 62 | Opam-user-setup support Merlin. 63 | 64 | $ opam user-setup install 65 | 66 | should take care of basic setup. 67 | See https://github.com/OCamlPro/opam-user-setup""" 68 | {success & !user-setup:installed} 69 | dev-repo: "git+https://github.com/ocaml/merlin.git" 70 | url { 71 | src: 72 | "https://github.com/ocaml/merlin/releases/download/v3.2.2/merlin-v3.2.2.tbz" 73 | checksum: "md5=ede35b65f8ac9c440cfade5445662c54" 74 | } 75 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Starter pipeline 2 | # Start with a minimal pipeline that you can customize to build and deploy your code. 3 | # Add steps that build, run tests, deploy, and more: 4 | # https://aka.ms/yaml 5 | 6 | 7 | name: $(Build.SourceVersion) 8 | jobs: 9 | - job: Linux 10 | timeoutInMinutes: 0 11 | pool: 12 | vmImage: 'Ubuntu 16.04' 13 | 14 | variables: 15 | STAGING_DIRECTORY: /home/vsts/STAGING 16 | STAGING_DIRECTORY_UNIX: /home/vsts/STAGING 17 | ESY__CACHE_INSTALL_PATH: /home/vsts/.esy/3_____________________________________________________________________/i 18 | ESY__CACHE_SOURCE_TARBALL_PATH: /home/vsts/.esy/source/i 19 | # ESY__NPM_ROOT: /opt/hostedtoolcache/node/8.14.0/x64/lib/node_modules/esy 20 | 21 | steps: 22 | - template: .ci/use-node.yml 23 | - template: .ci/restore-build-cache.yml 24 | - template: .ci/esy-build-steps.yml 25 | - template: .ci/publish-build-cache.yml 26 | 27 | - job: MacOS 28 | timeoutInMinutes: 0 29 | pool: 30 | vmImage: 'macOS 10.13' 31 | 32 | variables: 33 | STAGING_DIRECTORY: /Users/vsts/STAGING 34 | STAGING_DIRECTORY_UNIX: /Users/vsts/STAGING 35 | ESY__CACHE_INSTALL_PATH: /Users/vsts/.esy/3____________________________________________________________________/i 36 | ESY__CACHE_SOURCE_TARBALL_PATH: /Users/vsts/.esy/source/i 37 | # ESY__NPM_ROOT: /usr/local/lib/node_modules/esy 38 | 39 | steps: 40 | - template: .ci/use-node.yml 41 | - template: .ci/restore-build-cache.yml 42 | - template: .ci/esy-build-steps.yml 43 | - template: .ci/publish-build-cache.yml 44 | 45 | - job: Windows 46 | timeoutInMinutes: 0 47 | pool: 48 | vmImage: 'vs2017-win2016' 49 | 50 | variables: 51 | STAGING_DIRECTORY: C:\Users\VssAdministrator\STAGING 52 | STAGING_DIRECTORY_UNIX: /C/Users/VssAdministrator/STAGING 53 | ESY__CACHE_INSTALL_PATH: /C/Users/VssAdministrator/.esy/3_/i 54 | ESY__CACHE_SOURCE_TARBALL_PATH: /C/Users/VssAdministrator/.esy/source/i 55 | # ESY__NPM_ROOT: /C/npm/prefix/node_modules/esy 56 | 57 | steps: 58 | - template: .ci/use-node.yml 59 | - template: .ci/restore-build-cache.yml 60 | - template: .ci/esy-build-steps.yml 61 | - template: .ci/publish-build-cache.yml 62 | 63 | - job: Release 64 | timeoutInMinutes: 0 65 | displayName: Release 66 | dependsOn: 67 | - Linux 68 | - MacOS 69 | - Windows 70 | condition: succeeded() 71 | pool: 72 | vmImage: ubuntu-16.04 73 | steps: 74 | - task: PublishBuildArtifacts@1 75 | displayName: 'Release Package' 76 | inputs: 77 | PathtoPublish: '.' 78 | ArtifactName: npm-package 79 | 80 | 81 | # - name: release 82 | # jobs: 83 | # - job: Release 84 | # timeoutInMinutes: 0 85 | # displayName: Release 86 | # pool: 87 | # vmImage: ubuntu-16.04 88 | # steps: 89 | # - task: GitHubRelease@0 90 | # inputs: 91 | # gitHubConnection: jaredly 92 | # repositoryName: '$(Build.Repository.Name)' 93 | # action: 'create' 94 | # target: '$(Build.SourceVersion)' 95 | # tagSource: manual 96 | # tag: $(Release Tag) 97 | # isDraft: true 98 | # addChangeLog: true -------------------------------------------------------------------------------- /src/Lockfile.re: -------------------------------------------------------------------------------- 1 | open Migrate_parsetree.Ast_407; 2 | open TypeMapSerde.Config; 3 | module Json = Vendor.Json; 4 | module Locked = TypeMapSerde.Config.Locked; 5 | 6 | let getStringPayload = payload => 7 | switch (Upgrade.getExpr(payload)) { 8 | | Some({Parsetree.pexp_desc: Pexp_constant(Pconst_string(text, _))}) => Some(text) 9 | | _ => None 10 | }; 11 | 12 | let getRenames = attributes => 13 | attributes->Belt.List.keepMap((({Location.txt}, payload)) => 14 | switch (Util.Utils.split_on_char('.', txt)) { 15 | | ["rename", name] => 16 | switch (getStringPayload(payload)) { 17 | | None => None 18 | | Some(string) => Some((name, string)) 19 | } 20 | | _ => None 21 | } 22 | ); 23 | 24 | let compareAttributes = (one, two) => { 25 | let one = one->getRenames->Belt.List.sort(compare); 26 | let two = two->getRenames->Belt.List.sort(compare); 27 | one == two; 28 | }; 29 | 30 | let compareTypes = 31 | ( 32 | oldType: SharedTypes.SimpleType.declaration('source), 33 | newType: SharedTypes.SimpleType.declaration('source), 34 | ) => { 35 | oldType.name == newType.name 36 | && oldType.variables == newType.variables 37 | && { 38 | // print_endline("Comparing"); 39 | switch (oldType.body, newType.body) { 40 | | (Variant(olds), Variant(news)) => 41 | olds->Belt.List.every(one => news->Belt.List.has(one, (==))) 42 | | _ => oldType.body == newType.body 43 | }; 44 | }; 45 | }; 46 | 47 | /** Checks that all types in the old map are the same in the new map */ 48 | let allTypesPreserved = (oldLockedTypes, newLockedTypes) => { 49 | Hashtbl.fold( 50 | (k, (attributes, v), good) => 51 | good 52 | && Hashtbl.mem(newLockedTypes, k) 53 | && { 54 | let (attributes2, v2) = Hashtbl.find(newLockedTypes, k); 55 | compareTypes(v, v2) && compareAttributes(attributes, attributes2); 56 | }, 57 | oldLockedTypes, 58 | true, 59 | ); 60 | }; 61 | 62 | let parseLockfile = (~override, config, lockedEntries, currentTypeMap, lockFilePath) => { 63 | switch (Files.readFileResult(lockFilePath)) { 64 | | Error(_) => {Locked.versions: [|{typeMap: currentTypeMap, entries: lockedEntries}|]} 65 | | Ok(contents) => 66 | let json = Json.parse(contents); 67 | let%try_force lockfile = 68 | switch (TypeMapSerde.lockfileFromJson(json)) { 69 | | Error(m) => Error(String.concat("::", m)) 70 | | Ok(v) => Ok(v) 71 | }; 72 | let latestVersion = Locked.getLatestVersion(lockfile); 73 | if (latestVersion == config.version) { 74 | if (!allTypesPreserved(lockfile->Locked.getVersion(config.version).typeMap, currentTypeMap) 75 | && !override) { 76 | failwith( 77 | "Types do not match lockfile! You must increment the version number in your types.json", 78 | ); 79 | } else { 80 | lockfile->Locked.updateVersion(~typeMap=currentTypeMap, ~entries=lockedEntries); 81 | }; 82 | } else if (latestVersion + 1 == config.version) { 83 | lockfile->Locked.addVersion(~typeMap=currentTypeMap, ~entries=lockedEntries); 84 | } else { 85 | failwith("Version must be incremented by one"); 86 | }; 87 | }; 88 | }; -------------------------------------------------------------------------------- /src/type-map/SerializeSimplerType.re: -------------------------------------------------------------------------------- 1 | open SharedTypes.SimpleType; 2 | open Util.JsonShort; 3 | 4 | let sourceToJson = source => 5 | switch (source) { 6 | | DigTypes.NotFound(_) => s("NotFound") 7 | | Public({DigTypes.uri, modulePath, name, moduleName}) => 8 | o([ 9 | ("uri", s(uri)), 10 | ("moduleName", s(moduleName)), 11 | ("modulePath", l(modulePath->Belt.List.map(s))), 12 | ("name", s(name)), 13 | ]) 14 | | DigTypes.Builtin(name) => o([("builtin", s(name))]) 15 | }; 16 | 17 | let rec toJson = (sourceToJson, t) => 18 | switch (t) { 19 | | Variable(string) => l([s("Variable"), s(string)]) 20 | | AnonVariable => s("AnonVariable") 21 | | RowVariant(rows, _closed) => 22 | l([ 23 | s("RowVariant"), 24 | l( 25 | rows->Belt.List.map(((label, expr)) => { 26 | o([ 27 | ("label", s(label)), 28 | ( 29 | "arg", 30 | switch (expr) { 31 | | None => null 32 | | Some(expr) => toJson(sourceToJson, expr) 33 | }, 34 | ), 35 | ]) 36 | }), 37 | ), 38 | ]) 39 | | Reference(source, args) => 40 | l([ 41 | s("Reference"), 42 | sourceToJson(source), 43 | l(args->Belt.List.map(toJson(sourceToJson))), 44 | ]) 45 | | Tuple(items) => 46 | l([s("Tuple"), l(items->Belt.List.map(toJson(sourceToJson)))]) 47 | | Fn(args, result) => 48 | l([ 49 | s("Fn"), 50 | l( 51 | args->Belt.List.map(((label, arg)) => 52 | o([ 53 | ("arg", toJson(sourceToJson, arg)), 54 | ( 55 | "label", 56 | switch (label) { 57 | | None => Vendor.Json.Null 58 | | Some(text) => s(text) 59 | }, 60 | ), 61 | ]) 62 | ), 63 | ), 64 | toJson(sourceToJson, result), 65 | ]) 66 | | Other => s("*other*") 67 | }; 68 | 69 | let exprToJson = (sourceToJson, body) => { 70 | switch (body) { 71 | | Open => s("Open") 72 | | Abstract => s("Abstract") 73 | | Expr(expr) => l([s("Expr"), toJson(sourceToJson, expr)]) 74 | | Record(items) => 75 | l([ 76 | s("Record"), 77 | o( 78 | items->Belt.List.map(((label, typ)) => 79 | (label, toJson(sourceToJson, typ)) 80 | ), 81 | ), 82 | ]) 83 | | Variant(constructors) => 84 | l([ 85 | s("Variant"), 86 | l( 87 | constructors->Belt.List.map(((name, args, res)) => 88 | o([ 89 | ("name", s(name)), 90 | ("args", l(args->Belt.List.map(toJson(sourceToJson)))), 91 | ( 92 | "result", 93 | switch (res) { 94 | | None => Vendor.Json.Null 95 | | Some(arg) => toJson(sourceToJson, arg) 96 | }, 97 | ), 98 | ]) 99 | ), 100 | ), 101 | ]) 102 | }; 103 | }; 104 | 105 | let declToJson = (sourceToJson, {name, variables, body}) => 106 | o([ 107 | ("name", s(name)), 108 | ("variables", l(variables->Belt.List.map(toJson(sourceToJson)))), 109 | ("body", exprToJson(sourceToJson, body)), 110 | ]); 111 | -------------------------------------------------------------------------------- /src/Lockdown.re: -------------------------------------------------------------------------------- 1 | let typesAndDependencies = tbl => { 2 | let collector = Hashtbl.create(10); 3 | 4 | let rec loop = source => 5 | if (!Hashtbl.mem(collector, source)) { 6 | let (_attributes, decl) = Hashtbl.find(tbl, source); 7 | collector->Hashtbl.replace(source, `Reference(source)); 8 | 9 | let sources = 10 | SharedTypes.SimpleType.usedSources(decl) 11 | ->Belt.List.keepMap(source => 12 | switch (source) { 13 | | TypeMap.DigTypes.NotFound(_) => None 14 | // assert(false) 15 | | Builtin(_) => None 16 | | Public(s) => Some(s) 17 | } 18 | ); 19 | sources->Belt.List.forEach(loop); 20 | 21 | let contents = 22 | sources->Belt.List.reduce([`Plain(decl)], (result, source) => 23 | switch (collector->Hashtbl.find(source)) { 24 | | `Reference(what) => [`Reference(what), ...result] 25 | | `Resolved(items) => items @ result 26 | } 27 | ); 28 | 29 | collector->Hashtbl.replace(source, `Resolved(contents)); 30 | }; 31 | 32 | Hashtbl.iter((key, _value) => loop(key), tbl); 33 | 34 | let collected = Hashtbl.create(10); 35 | collector 36 | |> Hashtbl.iter((key, value) => 37 | switch (value) { 38 | | `Resolved(items) => collected->Hashtbl.replace(key, items) 39 | | _ => assert(false) 40 | } 41 | ); 42 | 43 | // Printexc. 44 | 45 | let resolve = (source, items) => { 46 | // print_endline("Resolve " ++ string_of_int(List.length(items))); 47 | // print_endline( 48 | // Printexc.raw_backtrace_to_string(Printexc.get_callstack(100)), 49 | // ); 50 | let (unresolved, contents) = 51 | List.fold_left( 52 | ((unresolved, contents), item) => 53 | switch (item) { 54 | | `Reference(inner) when inner == source => (unresolved, contents) 55 | | `Reference(inner) => ( 56 | true, 57 | collected->Hashtbl.find(inner) @ contents, 58 | ) 59 | | `Plain(x) => (unresolved, [`Plain(x), ...contents]) 60 | }, 61 | (false, []), 62 | items, 63 | ); 64 | // print_endline("Resolve1"); 65 | Hashtbl.replace(collected, source, contents); 66 | // print_endline("< Resolve"); 67 | unresolved; 68 | }; 69 | 70 | let rec loop = i => { 71 | let unresolved = 72 | Hashtbl.to_seq(collected)->List.of_seq 73 | |> List.fold_left( 74 | (unresolved, (k, v)) => resolve(k, v) || unresolved, 75 | false, 76 | ); 77 | // let unresolved = 78 | // Hashtbl.fold((k, v, unresolved) => resolve(k, v) || unresolved, collected, false); 79 | if (unresolved) { 80 | if (i > 1000) { 81 | failwith("Failed to resolve in 1000 iterations"); 82 | }; 83 | loop(i + 1); 84 | }; 85 | }; 86 | loop(0); 87 | 88 | let resolved = Hashtbl.create(10); 89 | collected 90 | |> Hashtbl.iter((k, v) => 91 | resolved->Hashtbl.replace( 92 | k, 93 | v 94 | ->Belt.List.map(item => 95 | switch (item) { 96 | | `Plain(x) => x 97 | | `Reference(_inner) => failwith("Unresolved reference") 98 | } 99 | ) 100 | ->Belt.List.sort(compare), 101 | ) 102 | ); 103 | resolved; 104 | }; 105 | -------------------------------------------------------------------------------- /bin/Main.re: -------------------------------------------------------------------------------- 1 | 2 | open Milk; 3 | 4 | let docs = {| 5 | Milk 🥛 : Stress-free serialization & deserialization for Reason/OCaml 6 | 7 | Usage: milk [config file] [options] 8 | 9 | If no config file is provided, `types.json` will be used if it exists, 10 | otherwise the `milk` section of esy.json or package.json will be used if 11 | it exists. 12 | 13 | Options: 14 | 15 | - --init : create a new config file for the current project 16 | 17 | (rarely used) 18 | 19 | - --override : Ignore current lockfile version, overriding conflicts. 20 | NOTE: This should only be passed if you have not stored any 21 | data using the currently generated serde, as it may now be 22 | unparseable. 23 | - --upvert : Convert a legacy config file (generated with a previous 24 | version of milk) to the current schema. 25 | 26 | |}; 27 | 28 | let die = text => { 29 | print_endline("Error: " ++ text); 30 | // print_newline(); 31 | print_endline(docs); 32 | exit(1); 33 | }; 34 | 35 | let help = () => { 36 | print_endline(docs); 37 | exit(1); 38 | }; 39 | 40 | let rec parse = argv => switch (argv) { 41 | | [] => (None, []) 42 | | [arg, ...rest] when (arg != "" && arg.[0] == '-') => 43 | let (config, opts) = parse(rest); 44 | (config, [arg, ...opts]) 45 | | [arg, ...rest] => 46 | let (config, opts) = parse(rest); 47 | if (config == None) { 48 | (Some(arg), opts) 49 | } else { 50 | die("Multiple non-option arguments given. At most one expected (the config file)") 51 | } 52 | }; 53 | 54 | let readOrDie = configPath => { 55 | let text = try (Util.Files.readFileExn(configPath)) { 56 | | _ => die("Unable to read " ++ configPath) 57 | }; 58 | try (Json.parse(text)) { 59 | | _ => die("Invalid JSON in " ++ configPath) 60 | } 61 | }; 62 | 63 | let getNested = (json, fname) => { 64 | switch (json |> Json.get("milk")) { 65 | | None => die("No 'milk' section found in " ++ fname) 66 | | Some(json) => json 67 | } 68 | }; 69 | 70 | let args = switch (Sys.argv->Belt.List.fromArray) { 71 | | [_, ...args] => args 72 | | [] => [] 73 | }; 74 | 75 | switch (parse(args)) { 76 | | (_, opts) when opts->Belt.List.some(arg => arg == "-h" || arg == "--help") => help(); 77 | | (config, opts) when opts->Belt.List.some(arg => arg == "--init") => 78 | Milk.init(switch config { 79 | | None => "types.json" 80 | | Some(config) => config 81 | }) 82 | | (config, opts) => 83 | 84 | if (opts->Belt.List.has("-v", (==))) { 85 | 86 | Util.Log.spamError := true; 87 | Util.MerlinFile.debug := true; 88 | }; 89 | let (json, configPath) = switch config { 90 | | None => 91 | if (Files.exists("types.json")) { 92 | (readOrDie("types.json"), `Top("types.json")) 93 | } else if (Files.exists("esy.json")) { 94 | (readOrDie("esy.json")->getNested("esy.json"), `Nested("esy.json")) 95 | } else if (Files.exists("package.json")) { 96 | (readOrDie("package.json")->getNested("package.json"), `Nested("package.json")) 97 | } else { 98 | die("No config file provided") 99 | }; 100 | | Some(config) => (readOrDie(config), `Top(config)) 101 | }; 102 | let override = opts->Belt.List.has("--override", (==)); 103 | let upvert = opts->Belt.List.has("--upvert", (==)); 104 | main(~override, ~upvert, ~json, configPath) 105 | }; -------------------------------------------------------------------------------- /codemod/Codemod.re: -------------------------------------------------------------------------------- 1 | module Helpers = Helpers; 2 | 3 | let run = (~rootPath, ~filterPath, modify) => { 4 | let mainFile = 5 | Utils.startsWith(rootPath, ".") 6 | ? Filename.concat(Sys.getcwd(), rootPath) : rootPath; 7 | let mainFileUri = Util.Utils.toUri(mainFile); 8 | let state = Analyze.TopTypes.empty(); 9 | let state = { 10 | ...state, 11 | settings: { 12 | ...state.settings, 13 | recordAllLocations: true, 14 | autoRebuild: false, 15 | }, 16 | }; 17 | print_endline("Setting up a package"); 18 | // let%try_force package = Analyze.Packages.newPackageForRoot(~reportDiagnostics=(_, _) => (), state, root); 19 | let%try_force package = 20 | Analyze.Packages.getPackage( 21 | ~reportDiagnostics=(_, _) => (), 22 | mainFileUri, 23 | state, 24 | ); 25 | 26 | // let%opt_force (buildCommand, _) = package.buildCommand; 27 | // print_endline("Running build command (for freshness) " ++ buildCommand); 28 | // let (stdout, stderr, success) = Commands.execFull(~pwd=root, buildCommand); 29 | 30 | // if (!success) { 31 | // print_endline(Utils.joinLines(stdout)); 32 | // print_endline(Utils.joinLines(stderr)); 33 | // failwith("Build command " ++ buildCommand ++ " failed") 34 | // }; 35 | // if (Utils.joinLines(stderr) |> String.trim != "") { 36 | // print_endline(Utils.joinLines(stderr)); 37 | // failwith("Build command had stderror " ++ buildCommand) 38 | // }; 39 | 40 | let fullForCmt = 41 | ( 42 | switch (package.compilerVersion) { 43 | | Analyze.BuildSystem.V402 => Process_402.fullForCmt 44 | | V406 => Process_406.fullForCmt 45 | | V407 => Process_407.fullForCmt 46 | | V408 => Process_408.fullForCmt 47 | } 48 | )( 49 | ~allLocations=true, 50 | ); 51 | 52 | module Convert = 53 | Migrate_parsetree.Convert( 54 | Migrate_parsetree.OCaml_404, 55 | Migrate_parsetree.OCaml_407, 56 | ); 57 | module ConvertBack = 58 | Migrate_parsetree.Convert( 59 | Migrate_parsetree.OCaml_407, 60 | Migrate_parsetree.OCaml_404, 61 | ); 62 | 63 | package.Analyze.TopTypes.localModules 64 | ->Belt.List.forEach(moduleName => { 65 | let%opt_force paths = 66 | Utils.maybeHash(package.pathsForModule, moduleName); 67 | let%opt_consume (cmt, src) = SharedTypes.getImpl(paths); 68 | print_endline("Analyzing: " ++ src); 69 | 70 | if (filterPath(src, moduleName)) { 71 | let%try_force full = fullForCmt(~moduleName, cmt, src, x => x); 72 | let ctx = {Helpers.state, package, full}; 73 | 74 | let file_chan = open_in(src); 75 | seek_in(file_chan, 0); 76 | let lexbuf = Lexing.from_channel(file_chan); 77 | let (structure, comments) = 78 | Reason_toolchain.RE.implementation_with_comments(lexbuf); 79 | close_in(file_chan); 80 | let structure = Convert.copy_structure(structure); 81 | 82 | /* let%try_force structure = Process_406.parseTreeForCmt(cmt); */ 83 | let newStructure = modify(ctx, structure); 84 | 85 | if (newStructure != structure) { 86 | print_endline("Modified " ++ src); 87 | let structure = ConvertBack.copy_structure(newStructure); 88 | /* Pprintast.structure(Format.str_formatter, structure); */ 89 | Reason_toolchain.RE.print_implementation_with_comments( 90 | Format.str_formatter, 91 | (structure, comments), 92 | ); 93 | 94 | Files.writeFileExn(src, Format.flush_str_formatter()); 95 | }; 96 | }; 97 | }); 98 | }; 99 | -------------------------------------------------------------------------------- /example/for_codemodding/.ci/utils/restore-build-cache.yml: -------------------------------------------------------------------------------- 1 | # Steps for restoring project cache 2 | 3 | steps: 4 | - bash: 'mkdir -p $(STAGING_DIRECTORY_UNIX)' 5 | condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) 6 | displayName: '[Cache][Publish] Create cache directory' 7 | 8 | - task: Bash@3 9 | condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) 10 | displayName: '[Cache][Restore] Restoring build cache using REST API' 11 | continueOnError: true 12 | inputs: 13 | targetType: 'inline' # Optional. Options: filePath, inline 14 | script: | 15 | # If org name is reasonml then REST_BASE will be: https://dev.azure.com/reasonml/ 16 | REST_BASE="${SYSTEM_TEAMFOUNDATIONCOLLECTIONURI}" 17 | PROJ="$SYSTEM_TEAMPROJECT" 18 | ART_NAME="cache-${AGENT_OS}-install" 19 | fetchLatestBuild() { 20 | MASTER='branchName=refs%2Fheads%2Fmaster' 21 | FILTER='deletedFilter=excludeDeleted&statusFilter=completed&resultFilter=succeeded' 22 | LATEST='queryOrder=finishTimeDescending&$top=1' 23 | REST_BUILDS="$REST_BASE/$PROJ/_apis/build/builds?${FILTER}&${MASTER}&${LATEST}&api-version=4.1" 24 | echo "Rest call for builds: $REST_BUILDS" 25 | REST_BUILDS_RESP=$(curl "$REST_BUILDS") 26 | if [[ $REST_BUILDS_RESP =~ (\"web\":\{\"href\":\")([^\"]*) ]]; then LATEST_BUILD_PAGE="${BASH_REMATCH[2]}"; else LATEST_BUILD_PAGE=""; fi 27 | if [[ $REST_BUILDS_RESP =~ (\"badge\":\{\"href\":\")([^\"]*) ]]; then LATEST_BUILD_BADGE="${BASH_REMATCH[2]}"; else LATEST_BUILD_BADGE=""; fi 28 | if [[ $REST_BUILDS_RESP =~ (\"id\":)([^,]*) ]]; then LATEST_BUILD_ID="${BASH_REMATCH[2]}"; else LATEST_BUILD_ID=""; fi 29 | } 30 | fetchLatestBuild 31 | fetchArtifactURL() { 32 | REST_ART="$REST_BASE/$PROJ/_apis/build/builds/$LATEST_BUILD_ID/artifacts?artifactName=$ART_NAME&api-version=4.1" 33 | echo "Rest call for artifacts: $REST_ART" 34 | if [[ $(curl $REST_ART) =~ (downloadUrl\":\")([^\"]*) ]]; then LATEST_ART_URL="${BASH_REMATCH[2]}"; else LATEST_ART_URL=""; fi 35 | } 36 | downloadArtifact() { 37 | curl "$LATEST_ART_URL" > "${STAGING_DIRECTORY_UNIX}/$ART_NAME.zip" 38 | cd $STAGING_DIRECTORY_UNIX 39 | unzip "$ART_NAME.zip" 40 | } 41 | fetchArtifactURL 42 | echo "Using Dependency cache for buildID: $LATEST_BUILD_ID" 43 | echo "Build log for build that produced the cache: $LATEST_BUILD_PAGE" 44 | echo "Build badge for build that produced the cache: $LATEST_BUILD_BADGE" 45 | echo "Build artifact from build that produced the cache: $LATEST_ART_URL" 46 | downloadArtifact 47 | 48 | 49 | - bash: 'mkdir -p $(ESY__CACHE_INSTALL_PATH)' 50 | condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) 51 | displayName: '[Cache][Restore] Create esy cache directory' 52 | 53 | # - bash: 'cd $(ESY__NPM_ROOT) && tar -xf $(STAGING_DIRECTORY_UNIX)/cache-$(Agent.OS)-install/npm-cache.tar -C .' 54 | # continueOnError: true 55 | # condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) 56 | # displayName: '[Cache][Restore] Untar npm cache directory' 57 | 58 | - bash: 'cd $(ESY__CACHE_INSTALL_PATH) && tar -xf $(STAGING_DIRECTORY_UNIX)/cache-$(Agent.OS)-install/esy-cache.tar -C .' 59 | continueOnError: true 60 | condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) 61 | displayName: '[Cache][Restore] Untar esy cache directory' 62 | 63 | - bash: 'rm -rf *' 64 | continueOnError: true 65 | workingDirectory: '$(STAGING_DIRECTORY)' 66 | condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) 67 | displayName: '[Cache][Restore] Clean up' 68 | -------------------------------------------------------------------------------- /src/serde/OutputType.re: -------------------------------------------------------------------------------- 1 | open Migrate_parsetree.Ast_407; 2 | open Belt; 3 | 4 | open SharedTypes.SimpleType; 5 | 6 | let rx = Str.regexp("[^a-zA-Z_]"); 7 | 8 | let makeLockedTypeName = (moduleName, modulePath, name) => { 9 | String.concat( 10 | "__", 11 | ["_" ++ Str.global_replace(rx, "_", moduleName)] @ modulePath @ [name], 12 | ); 13 | }; 14 | 15 | let unflatten = items => 16 | switch (Longident.unflatten(items)) { 17 | | None => assert(false) 18 | | Some(lident) => lident 19 | }; 20 | 21 | let showSource = (source, args) => 22 | Ast_helper.Typ.constr( 23 | Location.mknoloc( 24 | switch (source) { 25 | | TypeMap.DigTypes.NotFound(s) => failwith("Not found type reference: " ++ s) 26 | | Builtin(name) => Longident.Lident(name) 27 | | Public((moduleName, modulePath, name)) => 28 | Longident.Lident(makeLockedTypeName(moduleName, modulePath, name)) 29 | }, 30 | ), 31 | args, 32 | ); 33 | 34 | let rec outputDeclaration = 35 | ( 36 | ~alias, 37 | moduleName, 38 | modulePath, 39 | name, 40 | showSource, 41 | declaration: SharedTypes.SimpleType.declaration('source), 42 | ) => { 43 | let declarationName: Ast_helper.str = 44 | Location.mknoloc(makeLockedTypeName(moduleName, modulePath, name)); 45 | let fullReference = 46 | switch (alias) { 47 | | None => None 48 | | Some(reference) => 49 | Some( 50 | Ast_helper.Typ.constr( 51 | Location.mknoloc(reference), 52 | declaration.variables->Belt.List.map(outputExpr(showSource)), 53 | ), 54 | ) 55 | }; 56 | 57 | let mk = 58 | Ast_helper.Type.mk( 59 | ~params= 60 | declaration.variables 61 | ->Belt.List.map(expr => 62 | (outputExpr(showSource, expr), Asttypes.Invariant) 63 | ), 64 | ); 65 | switch (declaration.body) { 66 | | Open 67 | /* mk(~kind=Parsetree.Ptype_open, declarationName) */ 68 | | Abstract => 69 | /* mk(~kind=Parsetree.Ptype_abstract, declarationName) */ 70 | mk(~manifest=?fullReference, declarationName) 71 | | Expr(expr) => 72 | mk(~manifest=outputExpr(showSource, expr), declarationName) 73 | | Record(items) => 74 | mk( 75 | ~manifest=?fullReference, 76 | ~kind= 77 | Parsetree.Ptype_record( 78 | items->List.map(((name, v)) => 79 | { 80 | Parsetree.pld_name: Location.mknoloc(name), 81 | pld_mutable: Asttypes.Immutable, 82 | pld_type: outputExpr(showSource, v), 83 | pld_loc: Location.none, 84 | pld_attributes: [], 85 | } 86 | ), 87 | ), 88 | declarationName, 89 | ) 90 | | Variant(items) => 91 | mk( 92 | ~manifest=?fullReference, 93 | ~kind= 94 | Parsetree.Ptype_variant( 95 | items->List.map(((name, contents, _result)) => 96 | Ast_helper.Type.constructor( 97 | ~args= 98 | Parsetree.Pcstr_tuple( 99 | contents->List.map(outputExpr(showSource)), 100 | ), 101 | Location.mknoloc(name), 102 | ) 103 | ), 104 | ), 105 | declarationName, 106 | ) 107 | }; 108 | } 109 | 110 | and outputExpr = 111 | (~mapVariable=name => Ast_helper.Typ.var(name), showSource, expr) => { 112 | Ast_helper.Typ.( 113 | switch (expr) { 114 | | Variable(name) => mapVariable(name) 115 | | AnonVariable => any() 116 | | RowVariant(rows, closed) => 117 | // print_endline("output " ++ Vendor.Json.stringify(TypeMap.SerializeSimplerType.toJson(x => Vendor.Json.String(""), expr))); 118 | variant( 119 | rows->Belt.List.map(((label, expr)) => { 120 | Parsetree.Rtag( 121 | Location.mknoloc(label), 122 | [], 123 | false, 124 | switch (expr) { 125 | | None => [] 126 | | Some(expr) => [outputExpr(~mapVariable, showSource, expr)] 127 | }, 128 | ) 129 | }), 130 | closed ? Closed : Open, 131 | None, 132 | ) 133 | | Reference(source, args) => 134 | showSource( 135 | source, 136 | args->List.map(outputExpr(~mapVariable, showSource)), 137 | ) 138 | | Tuple(items) => 139 | tuple(items->List.map(outputExpr(~mapVariable, showSource))) 140 | | Fn(args, result) => 141 | let rec loop = args => 142 | switch (args) { 143 | | [] => outputExpr(~mapVariable, showSource, result) 144 | | [(_label, arg), ...rest] => 145 | arrow( 146 | Nolabel, 147 | outputExpr(~mapVariable, showSource, arg), 148 | loop(rest), 149 | ) 150 | }; 151 | loop(args); 152 | | Other => failwith("unhandled expr type") 153 | } 154 | ); 155 | }; 156 | -------------------------------------------------------------------------------- /codemod/Helpers.re: -------------------------------------------------------------------------------- 1 | open Migrate_parsetree.Ast_407; 2 | open Parsetree; 3 | 4 | type ctx = { 5 | full: SharedTypes.full, 6 | state: Analyze.TopTypes.state, 7 | package: Analyze.TopTypes.package, 8 | }; 9 | 10 | let mapStr = (structure, strMapper) => { 11 | let mapper = { 12 | ...Ast_mapper.default_mapper, 13 | structure_item: (mapper, str) => 14 | switch (strMapper(mapper, str)) { 15 | | None => Ast_mapper.default_mapper.structure_item(mapper, str) 16 | | Some(str) => str 17 | }, 18 | }; 19 | mapper.structure(mapper, structure); 20 | }; 21 | 22 | let mapExpr = (expr, exprMapper) => { 23 | let mapper = { 24 | ...Ast_mapper.default_mapper, 25 | expr: (mapper, expr) => 26 | switch (exprMapper(mapper, expr)) { 27 | | None => Ast_mapper.default_mapper.expr(mapper, expr) 28 | | Some(expr) => expr 29 | }, 30 | }; 31 | mapper.expr(mapper, expr); 32 | }; 33 | 34 | let strExpr = (structure, exprMapper) => { 35 | let mapper = { 36 | ...Ast_mapper.default_mapper, 37 | expr: (mapper, expr) => 38 | switch (exprMapper(mapper, expr)) { 39 | | None => Ast_mapper.default_mapper.expr(mapper, expr) 40 | | Some(expr) => expr 41 | }, 42 | }; 43 | mapper.structure(mapper, structure); 44 | }; 45 | 46 | let rec collectFnArgs = expr => 47 | switch (expr.pexp_desc) { 48 | | Pexp_fun(label, defaultValue, pattern, body) => 49 | let (args, body) = collectFnArgs(body); 50 | ([(label, defaultValue, pattern), ...args], body); 51 | | _ => ([], expr) 52 | }; 53 | 54 | let rec makeFn = (args, body) => 55 | switch (args) { 56 | | [] => body 57 | | [(label, defaultValue, pattern), ...rest] => 58 | Ast_helper.Exp.fun_(label, defaultValue, pattern, makeFn(rest, body)) 59 | }; 60 | 61 | let rec mapFn = (mapper, expr) => 62 | switch (expr.pexp_desc) { 63 | | Pexp_fun(label, defaultValue, pattern, body) => { 64 | ...expr, 65 | pexp_desc: 66 | Pexp_fun( 67 | label, 68 | switch (defaultValue) { 69 | | None => None 70 | | Some(exp) => Some(mapper.Ast_mapper.expr(mapper, exp)) 71 | }, 72 | mapper.pat(mapper, pattern), 73 | mapFn(mapper, body), 74 | ), 75 | } 76 | | _ => mapper.expr(mapper, expr) 77 | }; 78 | 79 | let mapFnExpr = (expr, fnMapper) => { 80 | expr->mapExpr((mapper, expr) => 81 | switch (expr.pexp_desc) { 82 | | Pexp_fun(_) => 83 | let (args, body) = collectFnArgs(expr); 84 | switch (fnMapper(mapper, args, body)) { 85 | | Some((args, body)) => Some(makeFn(args, body)) 86 | | None => Some(mapFn(mapper, expr)) 87 | }; 88 | | _ => None 89 | } 90 | ); 91 | }; 92 | 93 | let mapConstructor = (expr, ~ident=?, constrMapper) => { 94 | expr->mapExpr((_mapper, expr) => 95 | switch (expr.pexp_desc) { 96 | | Pexp_construct({txt} as lid, Some({pexp_desc: Pexp_tuple(args)})) => 97 | switch (ident) { 98 | | None => constrMapper(lid, args, expr) 99 | | Some(ident) when ident == txt => constrMapper(lid, args, expr) 100 | | _ => None 101 | } 102 | | _ => None 103 | } 104 | ); 105 | }; 106 | 107 | // type extra = { 108 | // internalReferences: Hashtbl.t(int, list(Location.t)), 109 | // externalReferences: Hashtbl.t(string, list((path, tip, Location.t))), 110 | // mutable locations: list((Location.t, Loc.t)), 111 | // opens: Hashtbl.t(Location.t, openTracker), 112 | // }; 113 | 114 | let getExprType = (ctx, expr) => { 115 | let m = Format.asprintf("%a", Location.print_loc, expr.pexp_loc); 116 | 117 | // ctx.full.extra.locations->Belt.List.forEach(((location, loc)) => { 118 | // let t = switch loc { 119 | // | Typed(flex, typed) => SharedTypes.Loc.typedToString(typed) ++ " (" ++ flex.toString() ++ ")" 120 | // | Constant(_) => "Constant" 121 | // | Module(_) => "Module" 122 | // | TopLevelModule(string) => "TopLevelModule" 123 | // | TypeDefinition(_, _, _) => "TypeDefinition" 124 | // | Explanation(_) => "Explanation" 125 | // | Open => "Open" 126 | // | _ => "Not typed" 127 | // }; 128 | // Format.printf("Type at location: %a, %s@.", Location.print_loc, location, t); 129 | // }); 130 | 131 | let%try_force loc = 132 | References.locForLocations(~extra=ctx.full.extra, expr.pexp_loc) 133 | |> RResult.orError( 134 | "Could not find type for expr at " 135 | ++ m 136 | ++ ". Probably the ast & compiled artifacts are out of sync.", 137 | ); 138 | let env = Query.fileEnv(ctx.full.file); 139 | Log.log("Get file1"); 140 | let getModule = 141 | ctx.state->Analyze.State.fileForModule(~package=ctx.package); 142 | Log.log("Got file1"); 143 | switch (loc) { 144 | | Typed(typ, _) => 145 | SharedTypes.SimpleType.mapSource( 146 | TypeMap.GetTypeMap.mapSource(~env, ~getModule), 147 | typ.asSimpleType(), 148 | ) 149 | | _ => failwith("Location for expression was not Typed. This is a bug.") 150 | }; 151 | }; 152 | 153 | let getTypeDefinition = (ctx, {TypeMap.DigTypes.declared, env}) => { 154 | Log.log("Get file2"); 155 | let getModule = 156 | ctx.state->Analyze.State.fileForModule(~package=ctx.package); 157 | Log.log("Got file2"); 158 | SharedTypes.SimpleType.declMapSource( 159 | TypeMap.GetTypeMap.mapSource(~env, ~getModule), 160 | declared.contents.typ.asSimpleDeclaration(declared.name.txt), 161 | ); 162 | }; 163 | -------------------------------------------------------------------------------- /example/for_codemodding/.ci/release-postinstall.js: -------------------------------------------------------------------------------- 1 | /** 2 | * release-postinstall.js 3 | * 4 | * XXX: We want to keep this script installable at least with node 4.x. 5 | * 6 | * This script is bundled with the `npm` package and executed on release. 7 | * Since we have a 'fat' NPM package (with all platform binaries bundled), 8 | * this postinstall script extracts them and puts the current platform's 9 | * bits in the right place. 10 | */ 11 | 12 | var path = require("path"); 13 | var cp = require("child_process"); 14 | var fs = require("fs"); 15 | var os = require("os"); 16 | var platform = process.platform; 17 | 18 | var packageJson = require("./package.json"); 19 | var binariesToCopy = Object.keys(packageJson.bin) 20 | .map(function(name) { 21 | return packageJson.bin[name]; 22 | }) 23 | .concat(["esyInstallRelease.js"]); 24 | var foldersToCopy = ["bin", "_export"]; 25 | 26 | function copyRecursive(srcDir, dstDir) { 27 | var results = []; 28 | var list = fs.readdirSync(srcDir); 29 | var src, dst; 30 | list.forEach(function(file) { 31 | src = path.join(srcDir, file); 32 | dst = path.join(dstDir, file); 33 | 34 | var stat = fs.statSync(src); 35 | if (stat && stat.isDirectory()) { 36 | try { 37 | fs.mkdirSync(dst); 38 | } catch (e) { 39 | console.log("directory already exists: " + dst); 40 | console.error(e); 41 | } 42 | results = results.concat(copyRecursive(src, dst)); 43 | } else { 44 | try { 45 | fs.writeFileSync(dst, fs.readFileSync(src)); 46 | } catch (e) { 47 | console.log("could't copy file: " + dst); 48 | console.error(e); 49 | } 50 | results.push(src); 51 | } 52 | }); 53 | return results; 54 | } 55 | 56 | /** 57 | * Since os.arch returns node binary's target arch, not 58 | * the system arch. 59 | * Credits: https://github.com/feross/arch/blob/af080ff61346315559451715c5393d8e86a6d33c/index.js#L10-L58 60 | */ 61 | 62 | function arch() { 63 | /** 64 | * The running binary is 64-bit, so the OS is clearly 64-bit. 65 | */ 66 | if (process.arch === "x64") { 67 | return "x64"; 68 | } 69 | 70 | /** 71 | * All recent versions of Mac OS are 64-bit. 72 | */ 73 | if (process.platform === "darwin") { 74 | return "x64"; 75 | } 76 | 77 | /** 78 | * On Windows, the most reliable way to detect a 64-bit OS from within a 32-bit 79 | * app is based on the presence of a WOW64 file: %SystemRoot%\SysNative. 80 | * See: https://twitter.com/feross/status/776949077208510464 81 | */ 82 | if (process.platform === "win32") { 83 | var useEnv = false; 84 | try { 85 | useEnv = !!( 86 | process.env.SYSTEMROOT && fs.statSync(process.env.SYSTEMROOT) 87 | ); 88 | } catch (err) {} 89 | 90 | var sysRoot = useEnv ? process.env.SYSTEMROOT : "C:\\Windows"; 91 | 92 | // If %SystemRoot%\SysNative exists, we are in a WOW64 FS Redirected application. 93 | var isWOW64 = false; 94 | try { 95 | isWOW64 = !!fs.statSync(path.join(sysRoot, "sysnative")); 96 | } catch (err) {} 97 | 98 | return isWOW64 ? "x64" : "x86"; 99 | } 100 | 101 | /** 102 | * On Linux, use the `getconf` command to get the architecture. 103 | */ 104 | if (process.platform === "linux") { 105 | var output = cp.execSync("getconf LONG_BIT", { encoding: "utf8" }); 106 | return output === "64\n" ? "x64" : "x86"; 107 | } 108 | 109 | /** 110 | * If none of the above, assume the architecture is 32-bit. 111 | */ 112 | return "x86"; 113 | } 114 | 115 | // implementing it b/c we don't want to depend on fs.copyFileSync which appears 116 | // only in node@8.x 117 | function copyFileSync(sourcePath, destPath) { 118 | var data; 119 | try { 120 | data = fs.readFileSync(sourcePath); 121 | } catch (e) { 122 | console.log("Couldn't find " + sourcePath + " trying with .exe"); 123 | data = fs.readFileSync(sourcePath + ".exe"); 124 | sourcePath = sourcePath + ".exe"; 125 | } 126 | var stat = fs.statSync(sourcePath); 127 | fs.writeFileSync(destPath, data); 128 | fs.chmodSync(destPath, stat.mode); 129 | } 130 | 131 | var copyPlatformBinaries = platformPath => { 132 | var platformBuildPath = path.join(__dirname, "platform-" + platformPath); 133 | 134 | foldersToCopy.forEach(folderPath => { 135 | var sourcePath = path.join(platformBuildPath, folderPath); 136 | var destPath = path.join(__dirname, folderPath); 137 | 138 | copyRecursive(sourcePath, destPath); 139 | }); 140 | 141 | binariesToCopy.forEach(binaryPath => { 142 | var sourcePath = path.join(platformBuildPath, binaryPath); 143 | var destPath = path.join(__dirname, binaryPath); 144 | if (fs.existsSync(destPath)) { 145 | fs.unlinkSync(destPath); 146 | } 147 | copyFileSync(sourcePath, destPath); 148 | fs.chmodSync(destPath, 0777); 149 | }); 150 | }; 151 | 152 | try { 153 | fs.mkdirSync("_export"); 154 | } catch (e) { 155 | console.log("Could not create _export folder"); 156 | } 157 | 158 | switch (platform) { 159 | case "win32": 160 | if (arch() !== "x64") { 161 | console.warn("error: x86 is currently not supported on Windows"); 162 | process.exit(1); 163 | } 164 | 165 | copyPlatformBinaries("windows-x64"); 166 | break; 167 | case "linux": 168 | case "darwin": 169 | copyPlatformBinaries(platform); 170 | break; 171 | default: 172 | console.warn("error: no release built for the " + platform + " platform"); 173 | process.exit(1); 174 | } 175 | 176 | require("./esyInstallRelease"); 177 | -------------------------------------------------------------------------------- /src/type-map-serde/Config.re: -------------------------------------------------------------------------------- 1 | type simpleExpr = 2 | SharedTypes.SimpleType.expr( 3 | TypeMap.DigTypes.typeSource(TypeMap.DigTypes.shortReference), 4 | ); 5 | 6 | type simpleDeclaration = 7 | SharedTypes.SimpleType.declaration( 8 | TypeMap.DigTypes.typeSource(TypeMap.DigTypes.shortReference), 9 | ); 10 | 11 | [@rename.Rex_json "rex-json"] 12 | [@rename.Ezjsonm "ezjsonm"] 13 | [@rename.Bs_json "Js.Json"] 14 | [@rename.Yojson "yojson"] 15 | type engine = 16 | | Rex_json 17 | | Bs_json 18 | | Ezjsonm 19 | | Yojson; 20 | 21 | [@rename.module_ "module"] 22 | [@migrate.args custom => custom.args == 0 ? None : Some(custom.args)] 23 | type custom = { 24 | module_: string, 25 | path: list(string), 26 | name: string, 27 | args: option(int), 28 | }; 29 | 30 | [@rename.type_ "type"] 31 | [@migrate.engines entry => None] 32 | [@migrate.history entry => None] 33 | [@migrate.minVersion entry => None] 34 | type entry = { 35 | file: string, 36 | type_: string, 37 | // TODO: support this attribute (currently unused) 38 | engines: option(list(engine)), 39 | publicName: option(string), 40 | // TODO: support this attribute (currently unused) 41 | history: option(bool), 42 | // TODO: support this attribute (currently unused) 43 | minVersion: option(int), 44 | }; 45 | 46 | // type rexMode = Results | FullExceptions | ThinExceptions; 47 | 48 | // type rexJsonConfig = { 49 | // mode: rexMode, 50 | // }; 51 | type errorMode = 52 | | Result 53 | | TrackedExceptions 54 | | PlainExceptions; 55 | 56 | // TODO: support these options (currently ignored) 57 | type engineOptions = { 58 | tailCall: bool, 59 | deserializeErrorMode: errorMode, 60 | }; 61 | 62 | type engineConfig = { 63 | output: string, 64 | // a module name 65 | helpers: option(string), 66 | options: option(engineOptions), 67 | }; 68 | 69 | [@rename.rex_json "rex-json"] 70 | [@rename.bs_json "Js.Json"] 71 | type engines = { 72 | rex_json: option(engineConfig), 73 | bs_json: option(engineConfig), 74 | ezjsonm: option(engineConfig), 75 | yojson: option(engineConfig), 76 | }; 77 | 78 | let engineConfigs = engines => 79 | switch (engines) { 80 | | {rex_json: None, bs_json: Some(config)} => [(Bs_json, config)] 81 | | {rex_json: Some(config), bs_json: None} => [(Rex_json, config)] 82 | | {rex_json: Some(rex), bs_json: Some(bs)} => [ 83 | (Rex_json, rex), 84 | (Bs_json, bs), 85 | ] 86 | | {yojson: Some(config)} => [(Yojson, config)] 87 | | {rex_json: None, bs_json: None} => [] 88 | }; 89 | 90 | let engineConfigs = engines => { 91 | let result = []; 92 | let result = 93 | switch (engines) { 94 | | {rex_json: Some(config)} => [(Rex_json, config), ...result] 95 | | _ => result 96 | }; 97 | let result = 98 | switch (engines) { 99 | | {bs_json: Some(config)} => [(Bs_json, config), ...result] 100 | | _ => result 101 | }; 102 | let result = 103 | switch (engines) { 104 | | {ezjsonm: Some(config)} => [(Ezjsonm, config), ...result] 105 | | _ => result 106 | }; 107 | let result = 108 | switch (engines) { 109 | | {yojson: Some(config)} => [(Yojson, config), ...result] 110 | | _ => result 111 | }; 112 | result; 113 | }; 114 | 115 | let activeEngines = engines => engineConfigs(engines)->Belt.List.map(fst); 116 | 117 | type t = { 118 | version: int, 119 | schemaPropertyName: option(string), 120 | // TODO: support this attribute 121 | minVersion: option(int), 122 | lockedTypes: option(string), 123 | engines, 124 | globalEngines: option(list(engine)), 125 | entries: list(entry), 126 | custom: list(custom), 127 | }; 128 | 129 | let empty = { 130 | version: 1, 131 | schemaPropertyName: None, 132 | minVersion: None, 133 | lockedTypes: None, 134 | engines: { 135 | rex_json: None, 136 | bs_json: Some({output: "src/TypeSerde.re", helpers: None, options: None}), 137 | ezjsonm: None, 138 | yojson: None, 139 | }, 140 | globalEngines: None, 141 | entries: [ 142 | { 143 | file: "src/Types.re", 144 | type_: "config", 145 | publicName: None, 146 | engines: None, 147 | history: None, 148 | minVersion: None, 149 | }, 150 | ], 151 | custom: [], 152 | }; 153 | 154 | module Locked = { 155 | type lockedEntry = { 156 | moduleName: string, 157 | modulePath: list(string), 158 | // TODO: support engine versioning 159 | engines: list((engine, int)), 160 | name: string, 161 | }; 162 | 163 | type lockedConfig('reference) = { 164 | entries: list(lockedEntry), 165 | typeMap: TypeMap.DigTypes.typeMap('reference), 166 | }; 167 | 168 | type lockfile('reference) = {versions: array(lockedConfig('reference))}; 169 | 170 | let getLatestVersion = lockfile => Array.length(lockfile.versions); 171 | let getVersion = (lockfile, version) => lockfile.versions[version - 1]; 172 | let addVersion = (lockfile, ~typeMap, ~entries) => { 173 | // ...lockfile, 174 | versions: 175 | Belt.List.toArray( 176 | Belt.List.fromArray(lockfile.versions) @ [{typeMap, entries}], 177 | ), 178 | }; 179 | let updateVersion = (lockfile, ~typeMap, ~entries) => { 180 | // ...lockfile, 181 | versions: 182 | Belt.List.toArray( 183 | Belt.List.fromArray(lockfile.versions) 184 | ->Belt.List.reverse 185 | ->Belt.List.tailExn 186 | ->Belt.List.reverse 187 | @ [{typeMap, entries}], 188 | ), 189 | }; 190 | }; 191 | 192 | type basic = Locked.lockedConfig(TypeMap.DigTypes.shortReference); 193 | type typeMap = TypeMap.DigTypes.typeMap(TypeMap.DigTypes.shortReference); 194 | type serializableLockfile = Locked.lockfile(TypeMap.DigTypes.shortReference); 195 | -------------------------------------------------------------------------------- /src/type-map-serde/TransformHelpers.re: -------------------------------------------------------------------------------- 1 | // open Migrate_parsetree.Ast_407; 2 | 3 | open Vendor; 4 | open Util; 5 | 6 | let wrapError = value => 7 | switch (value) { 8 | | Error(m) => Error([m]) 9 | | Ok(v) => Ok(v) 10 | }; 11 | 12 | module ToCurrent = 13 | Migrate_parsetree.Convert( 14 | Migrate_parsetree.OCaml_407, 15 | Migrate_parsetree.OCaml_408, 16 | ); 17 | module FromCurrent = 18 | Migrate_parsetree.Convert( 19 | Migrate_parsetree.OCaml_408, 20 | Migrate_parsetree.OCaml_407, 21 | ); 22 | 23 | let deserialize_Migrate_parsetree__Ast_407__Parsetree__structure = json => 24 | { 25 | let%try text = RJson.string(json); 26 | let lexbuf = Stdlib.Lexing.from_string(text); 27 | Ok( 28 | FromCurrent.copy_structure(Parser.implementation(Lexer.token, lexbuf)), 29 | ); 30 | } 31 | |> wrapError; 32 | 33 | let serialize_Migrate_parsetree__Ast_407__Parsetree__structure = structure => { 34 | Pprintast.structure( 35 | Stdlib.Format.str_formatter, 36 | ToCurrent.copy_structure(structure), 37 | ); 38 | Json.String(Stdlib.Format.flush_str_formatter()); 39 | }; 40 | 41 | let deserialize_Migrate_parsetree__Ast_407__Parsetree__signature = json => 42 | { 43 | let%try text = RJson.string(json); 44 | let lexbuf = Stdlib.Lexing.from_string(text); 45 | Ok(FromCurrent.copy_signature(Parser.interface(Lexer.token, lexbuf))); 46 | } 47 | |> wrapError; 48 | 49 | let serialize_Migrate_parsetree__Ast_407__Parsetree__signature = data => { 50 | Pprintast.signature( 51 | Stdlib.Format.str_formatter, 52 | ToCurrent.copy_signature(data), 53 | ); 54 | Json.String(Stdlib.Format.flush_str_formatter()); 55 | }; 56 | 57 | let deserialize_Migrate_parsetree__Ast_407__Parsetree__pattern = json => 58 | { 59 | let%try text = RJson.string(json); 60 | let lexbuf = Stdlib.Lexing.from_string(text); 61 | Ok(FromCurrent.copy_pattern(Parser.parse_pattern(Lexer.token, lexbuf))); 62 | } 63 | |> wrapError; 64 | 65 | let serialize_Migrate_parsetree__Ast_407__Parsetree__pattern = data => { 66 | Pprintast.pattern( 67 | Stdlib.Format.str_formatter, 68 | ToCurrent.copy_pattern(data), 69 | ); 70 | Json.String(Stdlib.Format.flush_str_formatter()); 71 | }; 72 | 73 | let deserialize_Migrate_parsetree__Ast_407__Parsetree__core_type = 74 | (json) 75 | : result(Migrate_parsetree.Ast_407.Parsetree.core_type, list(string)) => 76 | { 77 | let%try text = RJson.string(json); 78 | let lexbuf = Stdlib.Lexing.from_string(text); 79 | let typ = Parser.parse_core_type(Lexer.token, lexbuf); 80 | Ok(FromCurrent.copy_core_type(typ)); 81 | } 82 | |> wrapError; 83 | 84 | let serialize_Migrate_parsetree__Ast_407__Parsetree__core_type = data => { 85 | Pprintast.core_type( 86 | Stdlib.Format.str_formatter, 87 | ToCurrent.copy_core_type(data), 88 | ); 89 | Json.String(Stdlib.Format.flush_str_formatter()); 90 | }; 91 | 92 | let deserialize_Migrate_parsetree__Ast_407__Parsetree__expression = json => 93 | { 94 | let%try text = RJson.string(json); 95 | let lexbuf = Stdlib.Lexing.from_string(text); 96 | Ok( 97 | FromCurrent.copy_expression( 98 | Parser.parse_expression(Lexer.token, lexbuf), 99 | ), 100 | ); 101 | } 102 | |> wrapError; 103 | 104 | let serialize_Migrate_parsetree__Ast_407__Parsetree__expression = data => { 105 | Pprintast.expression( 106 | Stdlib.Format.str_formatter, 107 | ToCurrent.copy_expression(data), 108 | ); 109 | Json.String(Stdlib.Format.flush_str_formatter()); 110 | }; 111 | 112 | let migrate_Stdlib__hashtbl__t = (keyMigrator, valueMigrator, data) => { 113 | let result = Hashtbl.create(10); 114 | data 115 | |> Stdlib.Hashtbl.iter((key, value) => 116 | Hashtbl.replace(result, keyMigrator(key), valueMigrator(value)) 117 | ); 118 | result; 119 | }; 120 | 121 | let deserialize_Belt__Belt_HashMapInt____t = (valueTransform, json) => { 122 | let map = Belt.HashMap.Int.make(~hintSize=10); 123 | let%try items = RJson.obj(json) |> wrapError; 124 | let rec loop = items => { 125 | switch (items) { 126 | | [] => Ok(map) 127 | | [(k, v), ...rest] => 128 | switch (int_of_string(k)) { 129 | | exception _ => Error(["Expected integer key: " ++ k]) 130 | | key => 131 | let%try value = valueTransform(v); 132 | map->Belt.HashMap.Int.set(key, value); 133 | loop(rest); 134 | } 135 | }; 136 | }; 137 | loop(items); 138 | }; 139 | 140 | let serialize_Belt__Belt_HashMapInt____t = (_valueTransform, _map) => { 141 | Json./* map->Belt.HashMap.Int.toArray; */ 142 | Null; 143 | /* map->Belt.HashMap.Int.reduce([], (result, key, value) => { 144 | [("one", Json.Null), ...result] 145 | })->Json.Object; */ 146 | }; 147 | 148 | let deserialize_Stdlib__hashtbl____t = (keyTransform, valueTransform, json) => { 149 | let%try items = RJson.array(json) |> wrapError; 150 | let count = List.length(items); 151 | let tbl = Hashtbl.create(count); 152 | let rec loop = items => { 153 | switch (items) { 154 | | [] => Ok(tbl) 155 | | [one, ...rest] => 156 | let%try items = RJson.array(one) |> wrapError; 157 | switch (items) { 158 | | [key, value] => 159 | let%try key = keyTransform(key); 160 | let%try value = valueTransform(value); 161 | Hashtbl.replace(tbl, key, value); 162 | loop(rest); 163 | | _ => Error(["Invalid object format"]) 164 | }; 165 | }; 166 | }; 167 | loop(items); 168 | }; 169 | 170 | let serialize_Stdlib__hashtbl____t = (keyTransform, valueTransform, tbl) => { 171 | Vendor.Json.Array( 172 | Hashtbl.fold( 173 | (key, value, result) => { 174 | [ 175 | Vendor.Json.Array([keyTransform(key), valueTransform(value)]), 176 | ...result, 177 | ] 178 | }, 179 | tbl, 180 | [], 181 | ) 182 | ->Belt.List.sort(compare), 183 | ); 184 | }; 185 | -------------------------------------------------------------------------------- /example/src/AllTypes.re: -------------------------------------------------------------------------------- 1 | 2 | module V1 = { 3 | type person = { 4 | name: string, 5 | age: int, 6 | coords: (float, float), 7 | parents: option((person, person)) 8 | }; 9 | 10 | type pet = 11 | | Dog 12 | | Cat 13 | 14 | type household = { 15 | people: list(person), 16 | pets: list(pet), 17 | }; 18 | 19 | let example = {people: [{name: "Me", age: 10, coords: (1., 2.), parents: None}], pets: [Dog]} 20 | }; 21 | 22 | module V2 = { 23 | [@migrate.age person => float_of_int(person.age * 7)] 24 | type person = { 25 | name: string, 26 | age: float, 27 | coords: (float, float), 28 | parents: option((person, person)) 29 | }; 30 | 31 | type pet = 32 | | Dog 33 | | Cat 34 | 35 | type household = { 36 | people: list(person), 37 | pets: list(pet), 38 | }; 39 | 40 | let example = {people: [{name: "Me", age: 10., coords: (1., 3.), parents: None}], pets: [Dog]} 41 | }; 42 | 43 | module V2_1 = { 44 | [@migrate.age person => float_of_int(person.age * 7)] 45 | type person = { 46 | name: string, 47 | age: float, 48 | coords: (float, float), 49 | parents: option((person, person)) 50 | }; 51 | 52 | type pet = 53 | | Dog 54 | | Cat 55 | | Mouse 56 | 57 | type household = { 58 | people: list(person), 59 | pets: list(pet), 60 | }; 61 | 62 | let example = {people: [{name: "Me", age: 10., coords: (1., 3.), parents: None}], pets: [Dog]} 63 | }; 64 | 65 | module V3 = { 66 | type person = { 67 | name: string, 68 | age: float, 69 | coords: (float, float) 70 | }; 71 | 72 | type pet = 73 | | Dog 74 | | Cat 75 | | Mouse 76 | 77 | type household = { 78 | people: list(person), 79 | pets: list(pet), 80 | }; 81 | 82 | let example = {people: [{name: "Me", age: 10., coords: (2., 4.)}], pets: [Dog]} 83 | }; 84 | 85 | module V4 = { 86 | type person = V3.person = { 87 | name: string, 88 | age: float, 89 | coords: (float, float) 90 | }; 91 | 92 | type dogBreed = 93 | | Schnouser 94 | | Lab 95 | | Retriever 96 | | Poodle; 97 | 98 | [@migrate.Dog (Dog) => Dog(None)] 99 | type pet = 100 | | Dog(option(dogBreed)) 101 | | Cat 102 | | Mouse 103 | 104 | type household = { 105 | people: list(person), 106 | pets: list(pet), 107 | }; 108 | 109 | let example = {people: [{name: "Me", age: 10., coords: (5., 6.)}], pets: [Dog(Some(Schnouser))]} 110 | }; 111 | 112 | module V5 = { 113 | type person = V3.person = { 114 | name: string, 115 | age: float, 116 | coords: (float, float) 117 | }; 118 | 119 | [@migrate.Schnouser (Schnouser) => Schnouser("white")] 120 | type dogBreed = 121 | | Schnouser(string) 122 | | Lab 123 | | Retriever 124 | | Poodle 125 | 126 | type pet = 127 | | Dog(option(dogBreed)) 128 | | Cat 129 | | Mouse 130 | 131 | type named('a) = { 132 | name: string, 133 | contents: 'a 134 | }; 135 | 136 | [@migrate.county household => {name: "Nowhere", contents: 0}] 137 | type household = { 138 | people: list(person), 139 | pets: list(pet), 140 | county: named(int) 141 | }; 142 | 143 | let example = { 144 | people: [{name: "Me", age: 10., coords: (5., 6.)}], 145 | pets: [Dog(Some(Schnouser("black")))], 146 | county: {name: "Bearland", contents: 5} 147 | }; 148 | }; 149 | 150 | module V6 = { 151 | type person = { 152 | name: string, 153 | age: float, 154 | coords: (float, float) 155 | }; 156 | 157 | [@migrate.Dog (Dog(dogBreed)) => Dog] 158 | [@rename.Dog "a-cat"] 159 | type pet = 160 | | Dog 161 | | Cat 162 | | Mouse; 163 | 164 | [@migrate (contentsMigrator, named) => {name: named.name, contents: contentsMigrator(named.contents), isClosed: false}] 165 | [@rename.name "the name"] 166 | type named('a) = { 167 | name: string, 168 | contents: 'a, 169 | isClosed: bool, 170 | }; 171 | 172 | type what('a) = Now('a); 173 | 174 | [@migrate.visitors household => []] 175 | [@migrate.what household => Now("4")] 176 | type household = { 177 | people: list(person), 178 | pets: list(pet), 179 | what: what(string), 180 | visitors: list(person), 181 | county: named(int) 182 | }; 183 | 184 | let example = { 185 | people: [{name: "Me", age: 10., coords: (5., 6.)}], 186 | pets: [Dog, Mouse], 187 | what: Now("5"), 188 | visitors: [{name: "Friend", age: 11.5, coords: (1., 6.)}], 189 | county: {name: "Bearland", contents: 5, isClosed: false} 190 | }; 191 | }; 192 | 193 | /* 194 | Issues 195 | - can't export parameterized types 196 | 197 | */ 198 | 199 | module V7 = { 200 | [@migrate.thing (_) => `one] 201 | type person = { 202 | name: string, 203 | age: float, 204 | thing: [`one | `two | `three], 205 | coords: (float, float) 206 | }; 207 | 208 | [@rename.Dog "a-cat"] 209 | type pet = 210 | | Dog 211 | | Cat 212 | | Mouse; 213 | 214 | [@rename.name "the name"] 215 | [@migrate.other (_) => None] 216 | type named('a) = { 217 | name: string, 218 | contents: 'a, 219 | isClosed: bool, 220 | other: option('a) 221 | }; 222 | 223 | [@migrate.Now (Now(a)) => Now(_migrator_a(a), 5)] 224 | type what('a) = Now('a, int); 225 | 226 | /* designed to trigger record key collision */ 227 | type one = {key: string}; 228 | type two = {key: string}; 229 | 230 | [@migrate.one h => Now({key: "one"}, 5)] 231 | [@migrate.two h => Now({key: "two"}, 5)] 232 | type household = { 233 | one: what(one), 234 | two: what(two), 235 | people: list(person), 236 | pets: list(pet), 237 | what: what(string), 238 | visitors: list(person), 239 | county: named(int) 240 | }; 241 | 242 | let example = { 243 | one: Now({key: "one"}, 5), 244 | two: Now({key: "two"}, 5), 245 | people: [{name: "Me", age: 10., coords: (5., 6.), thing: `one}], 246 | pets: [Dog, Mouse], 247 | what: Now("5", 5), 248 | visitors: [{name: "Friend", age: 11.5, coords: (1., 6.), thing: `one}], 249 | county: {name: "Bearland", contents: 5, isClosed: false, other: None} 250 | }; 251 | }; 252 | 253 | module All = { 254 | type normalRecord = { 255 | a: int, 256 | b: string, 257 | c: (int, (string, float)), 258 | d: array(int), 259 | e: list(float), 260 | f: option(int) 261 | }; 262 | type recursive = A | B(recursive); 263 | type parameterizedRecord('a, 'b) = { 264 | a: 'a, 265 | b: 'b, 266 | c: (int, float), 267 | d: recursive, 268 | }; 269 | type normalVariant = A | B | C(int) | D(normalRecord); 270 | type parameterizedVariant('a, 'b) = PA | PB('a) | PC('a, 'b) | PD(parameterizedRecord('a, 'b)) | PE(normalVariant) | PF(normalRecord); 271 | type top = { 272 | contents: parameterizedVariant(int, array(float)), 273 | title: string, 274 | }; 275 | type rename = top; 276 | }; 277 | -------------------------------------------------------------------------------- /src/type-map/GetTypeMap.re: -------------------------------------------------------------------------------- 1 | open Migrate_parsetree.Ast_407; 2 | 3 | open Analyze; 4 | open DigTypes; 5 | 6 | let getType = (~env: Query.queryEnv, name) => { 7 | open Infix; 8 | let%try stamp = 9 | Query.hashFind(env.exported.types, name) 10 | |> RResult.orError( 11 | "No exported type " 12 | ++ name 13 | ++ " in module " 14 | ++ env.file.uri 15 | ++ " " 16 | ++ ( 17 | Stdlib.Hashtbl.to_seq_keys(env.exported.types)->Stdlib.List.of_seq 18 | |> String.concat(",") 19 | ), 20 | ); 21 | Query.hashFind(env.file.stamps.types, stamp) 22 | |> RResult.orError("Invalid stamp for " ++ name); 23 | }; 24 | 25 | let isBuiltin = 26 | fun 27 | | "list" 28 | | "string" 29 | | "option" 30 | | "int" 31 | | "float" 32 | | "bool" 33 | | "array" 34 | | "char" 35 | | "unit" 36 | | "int32" 37 | | "int64" 38 | | "nativeint" => true 39 | | _ => false; 40 | 41 | let rec getFullType_ = (env, path, name) => 42 | switch (path) { 43 | | [] => getType(~env, name) 44 | | [one, ...more] => 45 | let%try modStamp = 46 | Query.hashFind(env.exported.modules, one) 47 | |> RResult.orError("No exported module " ++ one); 48 | let%try declared = 49 | Query.hashFind(env.file.stamps.modules, modStamp) 50 | |> RResult.orError("Unexpected stamp " ++ string_of_int(modStamp)); 51 | switch (declared.contents) { 52 | | Ident(_) => 53 | Error("Expected a module, but " ++ one ++ " was an identifier") 54 | | Structure(contents) => 55 | getFullType_({...env, exported: contents.exported}, more, name) 56 | }; 57 | }; 58 | 59 | let getFullType = (~env: Query.queryEnv, path, name) => { 60 | getFullType_(env, path, name); 61 | }; 62 | 63 | let mapSource = (~env, ~getModule, path) => { 64 | let resolved = Query.resolveFromCompilerPath(~env, ~getModule, path); 65 | // print_endline("Resolved " ++ Path.name(path)); 66 | open Infix; 67 | let declared = 68 | switch (resolved) { 69 | | `Not_found => 70 | print_endline( 71 | "Unresolved " ++ Path.name(path) ++ " in " ++ env.file.uri, 72 | ); 73 | None; 74 | | `Stamp(stamp) => 75 | switch (Query.hashFind(env.file.stamps.types, stamp)) { 76 | | None => 77 | switch (Path.name(path)) { 78 | | x when isBuiltin(x) => None 79 | | _ => 80 | print_endline( 81 | "Bad stamp " 82 | ++ Path.name(path) 83 | ++ " in " 84 | ++ env.file.uri 85 | ++ " :: " 86 | ++ string_of_int(stamp), 87 | ); 88 | None; 89 | } 90 | | Some(decl) => Some((decl, env)) 91 | } 92 | /* |?>> (d => (d, env.file)) */ 93 | | `Exported(env, name) => 94 | switch (getType(~env, name)) { 95 | | Error(_) => None 96 | | Ok(d) => Some((d, env)) 97 | } 98 | }; 99 | switch (declared) { 100 | | None => 101 | switch (path) { 102 | | Path.Pident(ident) when isBuiltin(Ident.name(ident)) => 103 | Builtin(Ident.name(ident)) 104 | | _ => 105 | print_endline("!!! Not found " ++ Path.name(path)); 106 | NotFound(Path.name(path)); 107 | } 108 | | Some(({name, modulePath} as declared, env)) => 109 | let%try_force ((uri, moduleName), path) = 110 | Query.showVisibilityPath(~env, ~getModule, modulePath) 111 | |> RResult.orError("No visibility path"); 112 | Public({ 113 | uri, 114 | moduleName, 115 | declared, 116 | modulePath: path, 117 | name: name.txt, 118 | env, 119 | }); 120 | }; 121 | }; 122 | 123 | let recursiveMapSource = (~env, ~getModule, loop, path) => { 124 | let result = mapSource(~env, ~getModule, path); 125 | switch (result) { 126 | | Public({moduleName, modulePath: path, declared, name, env}) => 127 | // print_endline("Public, looping again"); 128 | loop(~env, (moduleName, path, name), declared) 129 | | _ => () 130 | }; 131 | 132 | result; 133 | }; 134 | // module FromCurrent = Migrate_parsetree.Convert(Migrate_parsetree.OCaml_408, Migrate_parsetree.OCaml_407); 135 | module FromCurrent = Migrate_parsetree_408_407_migrate; 136 | 137 | let rec digType = 138 | ( 139 | ~tbl, 140 | ~set, 141 | ~state, 142 | ~package, 143 | ~env, 144 | ~getModule, 145 | key, 146 | t: SharedTypes.declared(SharedTypes.Type.t), 147 | ) => 148 | if (!Hashtbl.mem(set, key)) { 149 | // let (a, b, c) = key; 150 | // print_endline( 151 | // "Dig " ++ a ++ " : " ++ String.concat(", ", b) ++ " : " ++ c, 152 | // ); 153 | let loop = digType(~tbl, ~set, ~state, ~package, ~getModule); 154 | Hashtbl.replace(set, key, ()); 155 | Hashtbl.replace( 156 | tbl, 157 | key, 158 | ( 159 | t.contents.typ.migrateAttributes() 160 | ->Belt.List.map(FromCurrent.copy_attribute), 161 | SharedTypes.SimpleType.declMapSource( 162 | recursiveMapSource(~env, ~getModule, loop), 163 | t.contents.typ.asSimpleDeclaration(t.name.txt), 164 | ), 165 | ), 166 | ); 167 | }; 168 | 169 | let splitFull = fullName => { 170 | let parts = Util.Utils.split_on_char('.', fullName); 171 | let rec loop = parts => 172 | switch (parts) { 173 | | [] => assert(false) 174 | | [one] => ([], one) 175 | | [one, ...more] => 176 | let (path, last) = loop(more); 177 | ([one, ...path], last); 178 | }; 179 | loop(parts); 180 | }; 181 | 182 | let fileToReference = (~state, uri, fullName) => { 183 | let%try package = 184 | Packages.getPackage(~reportDiagnostics=(_, _) => (), uri, state); 185 | let (path, name) = splitFull(fullName); 186 | let getModuleName = uri => { 187 | let%opt path = Utils.parseUri(uri); 188 | package.nameForPath->Query.hashFind(path); 189 | }; 190 | let%try_force moduleName = 191 | getModuleName(uri) |> RResult.orError("File to reference " ++ uri); 192 | Ok((moduleName, path, name)); 193 | }; 194 | 195 | let forInitialType = (~tbl, ~state, uri, fullName) => { 196 | let%try package = 197 | Packages.getPackage(~reportDiagnostics=(_, _) => (), uri, state); 198 | /* print_endline("Got package..."); */ 199 | let%try (file, _) = State.fileForUri(state, ~package, uri); 200 | let env = Query.fileEnv(file); 201 | let (path, name) = splitFull(fullName); 202 | let%try declared = getFullType(~env, path, name); 203 | Log.log("Get file"); 204 | let getModule = State.fileForModule(state, ~package); 205 | Log.log("Got file"); 206 | // For debugging module resolution 207 | // let getModule = path => { 208 | // print_endline("Finding file for module " ++ path); 209 | // Util.Log.spamError := true; 210 | // let res = State.fileForModule(state, ~package, path); 211 | // Util.Log.spamError := false; 212 | // res 213 | // }; 214 | let getModuleName = uri => { 215 | let%opt path = Utils.parseUri(uri); 216 | package.nameForPath->Query.hashFind(path); 217 | }; 218 | let moduleName = 219 | switch (getModuleName(uri)) { 220 | | None => 221 | print_endline("Paths"); 222 | package.nameForPath |> Hashtbl.iter((k, v) => {print_endline(k)}); 223 | package.pathsForModule 224 | |> Hashtbl.iter((moduleName, paths) => {print_endline(moduleName)}); 225 | raise(Failure("Entry file " ++ uri ++ " not processed / found")); 226 | | Some(moduleName) => moduleName 227 | }; 228 | // let%try_force moduleName = getModuleName(uri) |> RResult.orError("For initial type, no module name " ++ uri); 229 | let set = Hashtbl.create(10); 230 | Hashtbl.iter((k, _) => Hashtbl.replace(set, k, ()), tbl); 231 | ignore( 232 | digType( 233 | ~tbl, 234 | ~set, 235 | ~state, 236 | ~package, 237 | ~env, 238 | ~getModule, 239 | (moduleName, path, name), 240 | declared, 241 | ), 242 | ); 243 | 244 | Ok((moduleName, path, name)); 245 | }; 246 | 247 | let toSimpleMap = tbl => { 248 | let ntbl = Hashtbl.create(10); 249 | Hashtbl.iter( 250 | (key, (attributes, value)) => { 251 | Hashtbl.replace( 252 | ntbl, 253 | key, 254 | ( 255 | attributes, 256 | SharedTypes.SimpleType.declMapSource(DigTypes.toShortSource, value), 257 | ), 258 | ) 259 | }, 260 | tbl, 261 | ); 262 | ntbl; 263 | }; 264 | --------------------------------------------------------------------------------