salamynder / bs-mithril-test

Bucklescript generating mithril front end code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Buckle up Mithril!

Testing Mithril with Bucklescript

Workflow

  1. write js-ffi (in bucklescript) and normal ocaml code in src/
  2. npm run watch runs ninja build tool, compiles src-files to folder lib/js/src
  3. npm run bundle-watch runs webpack via entry lib/js/src/main.js, puts bundle under dist/
  4. browser-> public/index.html

Errors

don’t know how to call function in obj, i.e. this structure:

  • { [Function: m] mount: ”, … }
  • this object we get when var m = require(‘mithril’)
  • m here is mithrils m-helper which unifies a lot of functionality
  • this not working: external h : string -> string -> vnode = “m” [@@bs.module “mithril”]
    • SOLUTION: leave [@@bs.module] empty, i.e.:
      • external m : string -> string -> vnode = “mithril” [@@bs.module]
      • will generate: M(“span”, v[0])

duplicate code in mithril’s .ml and .mli files

  • when removing mli declarations, bsc complaining: unbound symbols

Reference

About

Bucklescript generating mithril front end code


Languages

Language:OCaml 87.5%Language:HTML 12.5%