diff --git a/.circleci/config.yml b/.circleci/config.yml index 60408e28..2c210468 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -93,7 +93,7 @@ commands: opam switch create . 4.06.1 --deps-only | cat fi opam env >> $BASH_ENV - + jobs: build_linux: executor: linux-opam @@ -103,7 +103,7 @@ jobs: - attach_workspace: at: ~/repo/artifacts - run: - # installs LTS v12 `node`, `npm`, `zip` and `m4` + # installs LTS v12 `node`, `npm`, `zip` and `m4` name: Install debian deps command: | sudo apt-get update @@ -121,7 +121,7 @@ jobs: - run: name: Install opam dev dependencies command: | - opam install reason.3.6.0 dune.1.11.4 ocaml-migrate-parsetree.1.3.1 ppx_tools_versioned uri --yes | cat + opam install reason.3.6.0 dune.1.11.4 uri --yes | cat - save-opam-cache - run: name: Build @@ -130,7 +130,7 @@ jobs: dune build - run: name: Test - command: ./_build/install/default/bin/rescript-editor-support.exe --help + command: ./_build/install/default/bin/rescript-editor-support.exe --help - run: name: Create tar file for executable command: | @@ -169,7 +169,7 @@ jobs: - run: name: Install opam dev dependencies command: | - opam install reason.3.6.0 dune.1.11.4 ocaml-migrate-parsetree.1.3.1 ppx_tools_versioned uri --yes | cat + opam install reason.3.6.0 dune.1.11.4 uri --yes | cat - save-opam-cache - run: name: Build @@ -177,7 +177,7 @@ jobs: dune build - run: name: Test - command: ./_build/install/default/bin/rescript-editor-support.exe --help + command: ./_build/install/default/bin/rescript-editor-support.exe --help - run: name: Create tar file for executable command: | @@ -229,7 +229,7 @@ jobs: command: | cd /cygdrive/c/Users/circleci/project eval $(opam env) - opam install reason.3.6.0 dune.1.11.4 ocaml-migrate-parsetree.1.3.1 ppx_tools_versioned uri --yes | cat + opam install reason.3.6.0 dune.1.11.4 uri --yes | cat - save_cache: key: v3-opam-cache-{{ arch }} paths: diff --git a/.gitignore b/.gitignore index 09ca694c..445fcd31 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,3 @@ editor-extensions/vscode/*.zip examples/*/node_modules examples/*/lib editor-extensions/vscode/node_modules - -# TODO: remove this after un-monadification -*.cm* -*.out -temp.txt diff --git a/rescript-editor-support.opam b/rescript-editor-support.opam index 3b83d9aa..7e64cb21 100644 --- a/rescript-editor-support.opam +++ b/rescript-editor-support.opam @@ -12,8 +12,6 @@ depends: [ "dune" {>= "2.7"} "ocaml" {= "4.06.1"} "reason" {= "3.6.0"} - "ocaml-migrate-parsetree" {>= "1.3.1" } - "ppx_tools_versioned" {>= "5.4.0"} "uri" {= "3.1.0"} ] build: [ diff --git a/src/ppx/Ppx_Monads.re b/src/ppx/Ppx_Monads.re deleted file mode 100644 index 1e7b687d..00000000 --- a/src/ppx/Ppx_Monads.re +++ /dev/null @@ -1,141 +0,0 @@ - -/** -Things I would like: - -// maybe this is overkill? also probably harder to parse -switch%opt (somethingOptional) { -| theContents => -}; - -// so each non-wildcard branch is wrapped in `Some`. Is this too weird? -switch%orNone (x) { - | each => case - | doesntNeed => toBe - | aSome => atTheEnd - | _ => None -} - -Alsoooo I really want to be able to provide -hover-for-explanation for %ppx extension points. -How could I do that in a general way? - -Done!!! As long as the ppx drops a `[@ocaml.explanation "some text"]` -somewhere, the `loc` of attribute's `loc(string)` bit will be used to -show the hover text that is the context of the attribute. - -[@ocaml.explanation {| - -``` -let%opt name = value; -otherStuff -``` -is transformed into -``` -switch (value) { - | None => None - | Some(name) => - otherStuff -} -``` -This means that `otherStuff` needs to end with an optional. - -If you want `otherStuff` to be automatically wrapped in `Some()`, -then use `let%opt_wrap`. -Alternatively, if you are just performing a side effect, and want -the result of the whole thing to be unit, use `let%consume`. -|}] - - */ - -open Migrate_parsetree -open OCaml_406.Ast - -/*** - * https://ocsigen.org/lwt/dev/api/Ppx_lwt - * https://github.com/zepalmer/ocaml-monadic - */ - -let rec process_bindings = (bindings) => - Parsetree.( - switch bindings { - | [] => assert false - | [binding] => (binding.pvb_pat, binding.pvb_expr) - | [binding, ...rest] => - let (pattern, expr) = process_bindings(rest); - ( - Ast_helper.Pat.tuple([binding.pvb_pat, pattern]), - [%expr Let_syntax.join2([%e binding.pvb_expr], [%e expr])] - ) - } - ); - -let opt_explanation = {| -Optional declaration sugar: -``` -let%opt name = value; -otherStuff -``` -is transformed into -``` -switch (value) { -| None => None -| Some(name) => - otherStuff -} -``` -This means that `otherStuff` needs to have type `option`. - -If you want `otherStuff` to be automatically wrapped in `Some()`, -then use `let%opt_wrap`. -Alternatively, if you are just performing a side effect, and want -the result of the whole thing to be unit, use `let%consume`. -|}; - - -let opt_consume_explanation = {| -Optional declaration sugar: -``` -let%consume name = value; -otherStuff -``` -is transformed into -``` -switch (value) { -| None => () -| Some(name) => - otherStuff -} -``` -This is intented for performing side-effects only -- `otherStuff` -must end up as type `unit`. -|}; - -let mapper = - Parsetree.{ - ...Ast_mapper.default_mapper, - expr: (mapper, expr) => - switch expr.pexp_desc { - | Pexp_extension(({txt: ( - "opt" | "opt_consume" - | "try" | "try_wrap" - ) as txt, loc}, PStr([{pstr_desc: Pstr_eval({pexp_desc: Pexp_let(Nonrecursive, bindings, continuation)}, _attributes)}]))) => { - let (front, explanation) = switch (txt) { - | "opt" => ([%expr Monads.Option.bind], opt_explanation) - | "opt_consume" => ([%expr Monads.Option.consume], opt_consume_explanation) - | "try" => ([%expr Monads.Result.bind], "Sugar for the Result type") - | "try_wrap" => ([%expr Monads.Result.map], "Sugar for the Result type - auto-wraps in `Ok()`") - | _ => assert(false) - }; - let (pat, expr) = process_bindings(bindings); - Ast_helper.Exp.attr( - [%expr [%e front]([%e mapper.expr(mapper, expr)], ~f=([%p pat]) => [%e mapper.expr(mapper, continuation)])], - ({txt: "ocaml.explanation", loc}, PStr([ - Ast_helper.Str.eval(Ast_helper.Exp.constant(Pconst_string(explanation, None))) - ])) - ) - } - | _ => Ast_mapper.default_mapper.expr(mapper, expr) - } - }; - -let () = Driver.register(~name="ppx_monads", ~args=[], Versions.ocaml_406, (_config, _cookies) => mapper); \ No newline at end of file diff --git a/src/ppx/dune b/src/ppx/dune deleted file mode 100644 index 83b14701..00000000 --- a/src/ppx/dune +++ /dev/null @@ -1,8 +0,0 @@ - -(library - (name Ppx_monads) - (flags :standard -w -9) - (libraries compiler-libs ocaml-migrate-parsetree ppx_tools_versioned) - (preprocess (pps ppx_tools_versioned.metaquot_406)) - (kind ppx_rewriter)) - diff --git a/src/ppx2/Ppx_Unmonads.re b/src/ppx2/Ppx_Unmonads.re deleted file mode 100644 index cf6f0b6e..00000000 --- a/src/ppx2/Ppx_Unmonads.re +++ /dev/null @@ -1,148 +0,0 @@ - -/** -Things I would like: - -// maybe this is overkill? also probably harder to parse -switch%opt (somethingOptional) { -| theContents => -}; - -// so each non-wildcard branch is wrapped in `Some`. Is this too weird? -switch%orNone (x) { - | each => case - | doesntNeed => toBe - | aSome => atTheEnd - | _ => None -} - -Alsoooo I really want to be able to provide -hover-for-explanation for %ppx extension points. -How could I do that in a general way? - -Done!!! As long as the ppx drops a `[@ocaml.explanation "some text"]` -somewhere, the `loc` of attribute's `loc(string)` bit will be used to -show the hover text that is the context of the attribute. - -[@ocaml.explanation {| - -``` -let%opt name = value; -otherStuff -``` -is transformed into -``` -switch (value) { - | None => None - | Some(name) => - otherStuff -} -``` -This means that `otherStuff` needs to end with an optional. - -If you want `otherStuff` to be automatically wrapped in `Some()`, -then use `let%opt_wrap`. -Alternatively, if you are just performing a side effect, and want -the result of the whole thing to be unit, use `let%consume`. -|}] - - */ - -/*** - * https://ocsigen.org/lwt/dev/api/Ppx_lwt - * https://github.com/zepalmer/ocaml-monadic - */ - -let rec process_bindings = (bindings) => - Parsetree.( - switch bindings { - | [] => assert false - | [binding] => (binding.pvb_pat, binding.pvb_expr) - | [binding, ...rest] => - let (pattern, expr) = process_bindings(rest); - ( - Ast_helper.Pat.tuple([binding.pvb_pat, pattern]), - [%expr Let_syntax.join2([%e binding.pvb_expr], [%e expr])] - ) - } - ); - -let opt_explanation = {| -Optional declaration sugar: -``` -let%opt name = value; -otherStuff -``` -is transformed into -``` -switch (value) { -| None => None -| Some(name) => - otherStuff -} -``` -This means that `otherStuff` needs to have type `option`. - -If you want `otherStuff` to be automatically wrapped in `Some()`, -then use `let%opt_wrap`. -Alternatively, if you are just performing a side effect, and want -the result of the whole thing to be unit, use `let%consume`. -|}; - - -let opt_consume_explanation = {| -Optional declaration sugar: -``` -let%consume name = value; -otherStuff -``` -is transformed into -``` -switch (value) { -| None => () -| Some(name) => - otherStuff -} -``` -This is intented for performing side-effects only -- `otherStuff` -must end up as type `unit`. -|}; - -let mapper = - Parsetree.{ - ...Ast_mapper.default_mapper, - expr: (mapper, expr) => - switch expr.pexp_desc { - | Pexp_extension(({txt: ( - "opt" | "opt_consume" - | "try" | "try_wrap" - ) as txt}, PStr([{pstr_desc: Pstr_eval({pexp_desc: Pexp_let(Nonrecursive, bindings, continuation)}, _attributes)}]))) => { - let (pat, expr) = process_bindings(bindings); - switch (txt) { - | "opt" => - [%expr [%e [%expr switch [%e mapper.expr(mapper, expr)] { - | None => None - | Some([%p pat]) => [%e mapper.expr(mapper, continuation)] - }]]] - | "opt_consume" => - [%expr [%e [%expr switch [%e mapper.expr(mapper, expr)] { - | None => () - | Some([%p pat]) => [%e mapper.expr(mapper, continuation)] - }]]] - | "try" => - [%expr [%e [%expr switch [%e mapper.expr(mapper, expr)] { - | Error(e) => Error(e) - | Ok([%p pat]) => [%e mapper.expr(mapper, continuation)] - }]]] - | "try_wrap" => - [%expr [%e [%expr switch [%e mapper.expr(mapper, expr)] { - | Error(e) => Error(e) - | Ok([%p pat]) => Ok([%e mapper.expr(mapper, continuation)]) - }]]] - | _ => assert(false) - }; - } - | _ => Ast_mapper.default_mapper.expr(mapper, expr) - } - }; - -let () = Ast_mapper.register("ppx_monads", (_) => mapper); \ No newline at end of file diff --git a/src/ppx2/dune b/src/ppx2/dune deleted file mode 100644 index 829fa965..00000000 --- a/src/ppx2/dune +++ /dev/null @@ -1,8 +0,0 @@ -(executable - (name Ppx_Unmonads) - (public_name ppx_unmonads.exe) - (flags :standard -w -9-3) - (libraries compiler-libs ppx_tools_versioned) - (preprocess (pps ppx_tools_versioned.metaquot_406)) - ) - diff --git a/src/rescript-editor-support/NewCompletions.re b/src/rescript-editor-support/NewCompletions.re index 87c30783..4f5dc6ce 100644 --- a/src/rescript-editor-support/NewCompletions.re +++ b/src/rescript-editor-support/NewCompletions.re @@ -200,9 +200,6 @@ let getEnvWithOpens = ~opens: list(Query.queryEnv), path, ) => - /* let%opt declared = ; */ - /* for ppx, I think I'd like a "if this is nonnull, bail w/ it". - So the opposite of let%opt - let%bail or something */ /* Query.resolvePath(~env, ~path, ~getModule) */ switch (Query.resolveFromStamps(~env, ~path, ~getModule, ~pos)) { | Some(x) => Some(x) diff --git a/src/rescript-editor-support/dune b/src/rescript-editor-support/dune index d40b63bc..8808247e 100644 --- a/src/rescript-editor-support/dune +++ b/src/rescript-editor-support/dune @@ -4,5 +4,4 @@ (public_name rescript-editor-support.exe) (libraries str compiler-libs.common uri unix) (flags "-w" "+26+27+32+33+39") - (preprocess (pps Ppx_monads)) ) diff --git a/unmonad.sh b/unmonad.sh deleted file mode 100755 index 4d93d6b6..00000000 --- a/unmonad.sh +++ /dev/null @@ -1,3 +0,0 @@ -file=BuildSystem -ocamlc -dsource -ppx _build/default/src/ppx2/Ppx_Unmonads.exe -pp "refmt --parse re --print binary" -I src -impl src/rescript-editor-support/$file.re &> ./temp.txt -# refmt --parse ml --print re ./temp.txt &> src/rescript-editor-support/$file.re