Skip to content

Instantly share code, notes, and snippets.

@chenglou
Last active June 21, 2017 09:42
Show Gist options
  • Save chenglou/54cf2f6e50d45da9905b78d676697c75 to your computer and use it in GitHub Desktop.
Save chenglou/54cf2f6e50d45da9905b78d676697c75 to your computer and use it in GitHub Desktop.
// Generated by BUCKLESCRIPT VERSION 1.7.5, PLEASE EDIT WITH CARE
'use strict';
function counter(state, action) {
var match = action.type;
switch (match) {
case 0 :
return state + 1 | 0;
case 1 :
return state - 1 | 0;
case 2 :
return state + 2 | 0;
}
}
function bump_counter() {
return {
type: /* Increment */0
};
}
var increment = /* Increment */0;
var decrement = /* Decrement */1;
var somethingElse = /* SomethingElse */2;
exports.increment = increment;
exports.decrement = decrement;
exports.somethingElse = somethingElse;
exports.counter = counter;
exports.bump_counter = bump_counter;
/* No side effect */
type actions =
| Increment
| Decrement
| SomethingElse
[@@bs.deriving {accessors: accessors}];
let counter ::state ::action =>
switch action##_type {
| Increment => state + 1
| Decrement => state - 1
| SomethingElse => state + 2
};
let bump_counter () => {"_type": Increment};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment