- Create a dune file:
(library
(public_name aggregate_ppx_name)
(kind ppx_rewriter)
(libraries ppx_deriving_protobuf other_ppx another_ppx))
- Build:
dune build --profile release
(library
(public_name aggregate_ppx_name)
(kind ppx_rewriter)
(libraries ppx_deriving_protobuf other_ppx another_ppx))
dune build --profile release
module State: { | |
type t('a); | |
let createSlot: (t('a) => 'b) => 'b; | |
let useHook: ('a, t('a)) => ('a, 'a => unit); | |
} = { | |
type t('a) = ref(option('a)); | |
let createSlot = cont => cont(ref(None)); | |
let useHook = (initial: 'a, slot: t('a)) => { | |
let state = | |
switch (slot^) { |
This is the base of all projects and it will include the foundation for all potential react-based projects in Reason.
This base package should include a ReasonReact api to promote collaboration and familiarity with people using a ReasonReact, and for the modern world of React this should also include a Hooks api that currently revery uses.
All blocks in Jsx are of type React.reactElement
. This reactElement should represent:
module Store = { | |
type action = | |
| Increase | |
| Decrease | |
| SetUsername(string); | |
type state = { | |
count: int, | |
username: string, | |
}; | |
type storeBag = { |
type field = | |
| O | |
| X; | |
type position = (field, field, field, field); | |
type unit = (position, position, position, position); | |
type units = list(unit); |
/* `action` and `state` types must be defined before the `let component` statement for type inference to work */ | |
type action = | |
| UpdateEmail string | |
| UpdatePassword string; | |
type state = { | |
email: string, | |
password: string | |
}; |
/** | |
* Making promises | |
*/ | |
let okPromise = Js.Promise.make((~resolve, ~reject as _) => [@bs] resolve("ok")); | |
/* Simpler promise creation for static values */ | |
Js.Promise.resolve("easy"); | |
Js.Promise.reject(Invalid_argument("too easy")); |
function recp () { | |
if [ $# -ge 1 -a -f "$1" ] | |
then | |
refmt --parse ml --print re "$@" | pbcopy; | |
else | |
pbpaste | refmt --parse ml --print re | pbcopy | |
fi | |
} |
"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType
The following write-up is intended as an introduction into using phantom types in ReasonML.
Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.
var gulp = require('gulp'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var source = require('vinyl-source-stream'); | |
var buffer = require('vinyl-buffer'); | |
var browserify = require('browserify'); | |
var watchify = require('watchify'); | |
var babel = require('babelify'); | |
function compile(watch) { | |
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel)); |