Giter Club home page Giter Club logo

bs-preact's Issues

looks like bs-platform7.0.1 breaks the ppx

Clone this repo. Update bs-platform to 7.0.1. Run npm start:

FAILED: examples/Clock.mlast 
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe  -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx  -o examples/Clock.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/examples/Clock.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/examples/Clock.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppx7ccba3' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppx1368f6'

[2/75] Building examples/Clicks.mlast
FAILED: examples/Clicks.mlast 
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe  -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx  -o examples/Clicks.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/examples/Clicks.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/examples/Clicks.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxcb25ae' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxe20fd1'

[3/75] Building tests/Preact_Test.mlast
FAILED: tests/Preact_Test.mlast 
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe  -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx  -o tests/Preact_Test.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/tests/Preact_Test.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/tests/Preact_Test.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxedbca4' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppx2f24ba'

[4/75] Building tests/Preact_Router_Test.mlast
FAILED: tests/Preact_Router_Test.mlast 
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe  -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx  -o tests/Preact_Router_Test.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/tests/Preact_Router_Test.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/tests/Preact_Router_Test.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxdd7638' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxd8c0b7'

[5/75] Building examples/Ref.mlast
FAILED: examples/Ref.mlast 
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe  -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx  -o examples/Ref.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/examples/Ref.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/examples/Ref.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppx202c9b' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxd56a9f'

[6/75] Building examples/Form.mlast
FAILED: examples/Form.mlast 
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe  -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx  -o examples/Form.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/examples/Form.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/examples/Form.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppx667943' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxc146e3'

FAILED: subcommand failed.
 ERROR  Command failed with exit code 2.
ERROR: "build:bsb" exited with 1.
 ERROR  Command failed with exit code 1.
➜  bs-preact-master 

show a .re example in readme

Users who prefer reason over ocaml syntax and who are unfamiliar with the usage of annotations like let [@hook] may have a hard time understanding where the annotations go in a Reason formatted codebase.

Putting this example:

let useDoubleReducer =
 fun [@preact.hook] (reducer, initialValue) ->
  let[@hook] state, dispatch = P.useReducer reducer initialValue in
  let dispatchTwice action =
    let () = dispatch action in
    dispatch action
  in
  state, dispatchTwice

let make =
 fun [@preact.component "HelloHooks"] () ->
  let reducer state action = state + action in
  let[@hook] state, dispatch = useDoubleReducer (reducer, 0) in
  P.button [ P.onClick (fun _ -> dispatch 2) ] [ P.int state ]

into the ReasonML playground outputs this:

let useDoubleReducer =
  [@preact.hook]
  (
    ((reducer, initialValue)) =>
      [@hook]
      {
        let (state, dispatch) = P.useReducer(reducer, initialValue);
        let dispatchTwice = action => {
          let () = dispatch(action);
          dispatch(action);
        };

        (state, dispatchTwice);
      }
  );

let make =
  [@preact.component "HelloHooks"]
  (
    () => {
      let reducer = (state, action) => state + action;
      [@hook]
      {
        let (state, dispatch) = useDoubleReducer((reducer, 0));
        P.button([P.onClick(_ => dispatch(2))], [P.int(state)]);
      };
    }
  );

As someone who does not know where annotations are supposed to go in Reason formatted code it is unclear if this translation is in fact correct.

PS: thanks for your work, really like the hooks validation at compile time 👌

Proposed solution

  • show a reasonml example
  • like to resources/docs on annotation usage in reasonml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.