Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to rescript #16

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "reason-react-examples",
"name": "multi-n-back",
"reason": {
"react-jsx": 3
},
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "multi-n-back",
"version": "0.1.0",
"scripts": {
"build": "bsb -make-world",
"start": "bsb -make-world -w -ws _ ",
"clean": "bsb -clean-world",
"build": "rescript",
"start": "rescript build -w",
"clean": "rescript clean",
"server": "moduleserve ./ --port 8000",
"clean-dist": "rimraf ./dist",
"build-dist": "yarn clean-dist && webpack --config ./webpack.config.js && cp ./indexProduction.html ./dist/index.html && cp ./favicon.ico ./dist/favicon.ico",
Expand All @@ -19,17 +19,18 @@
"author": "",
"license": "MIT",
"dependencies": {
"@glennsl/bs-jest": "^0.5.1",
"react": "^16.8.1",
"react-dom": "^16.8.1",
"@glennsl/bs-jest": "^0.7.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"reason-react": ">=0.7.0",
"rescript": "^9.1.4",
"rimraf": "^3.0.2",
"serve": "^11.3.2",
"webpack": "^4.41.6",
"webpack-cli": "^3.3.11"
"serve": "^12.0.0",
"webpack": "^5.52.0",
"webpack-cli": "^4.8.0"
},
"devDependencies": {
"bs-platform": "^8.2.0",
"bs-platform": "^9.0.2",
"moduleserve": "^0.9.0"
},
"jest": {
Expand Down
72 changes: 36 additions & 36 deletions src/App.bs.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
'use strict';

var List = require("bs-platform/lib/js/list.js");
var $$Array = require("bs-platform/lib/js/array.js");
var Curry = require("bs-platform/lib/js/curry.js");
var List = require("rescript/lib/js/list.js");
var $$Array = require("rescript/lib/js/array.js");
var Curry = require("rescript/lib/js/curry.js");
var React = require("react");
var Score$ReasonReactExamples = require("./GameCore/Score.bs.js");
var Answer$ReasonReactExamples = require("./GameCore/Answer.bs.js");
var Canvas$ReasonReactExamples = require("./GameCore/Canvas.bs.js");
var Modality$ReasonReactExamples = require("./GameCore/Modality/Modality.bs.js");
var GameState$ReasonReactExamples = require("./GameCore/GameState.bs.js");
var Statistics$ReasonReactExamples = require("./Interface/Statistics.bs.js");
var AnswerToggle$ReasonReactExamples = require("./Interface/AnswerToggle.bs.js");
var GameConfiguration$ReasonReactExamples = require("./GameCore/GameConfiguration.bs.js");
var ConfigurationPanel$ReasonReactExamples = require("./Interface/ConfigurationPanel.bs.js");
var ConfigurationTrigger$ReasonReactExamples = require("./Interface/ConfigurationTrigger.bs.js");
var Score$MultiNBack = require("./GameCore/Score.bs.js");
var Answer$MultiNBack = require("./GameCore/Answer.bs.js");
var Canvas$MultiNBack = require("./GameCore/Canvas.bs.js");
var Modality$MultiNBack = require("./GameCore/Modality/Modality.bs.js");
var GameState$MultiNBack = require("./GameCore/GameState.bs.js");
var Statistics$MultiNBack = require("./Interface/Statistics.bs.js");
var AnswerToggle$MultiNBack = require("./Interface/AnswerToggle.bs.js");
var GameConfiguration$MultiNBack = require("./GameCore/GameConfiguration.bs.js");
var ConfigurationPanel$MultiNBack = require("./Interface/ConfigurationPanel.bs.js");
var ConfigurationTrigger$MultiNBack = require("./Interface/ConfigurationTrigger.bs.js");

var initialConfig = GameConfiguration$ReasonReactExamples.makeDefault(undefined);
var initialConfig = GameConfiguration$MultiNBack.makeDefault(undefined);

var initialState_gameState = GameState$ReasonReactExamples.makeRandom(initialConfig);
var initialState_gameState = GameState$MultiNBack.makeRandom(initialConfig);

var initialState_answer = Answer$ReasonReactExamples.make(undefined);
var initialState_answer = Answer$MultiNBack.make(undefined);

var initialState_highScore = Score$ReasonReactExamples.getHighScore(undefined);
var initialState_highScore = Score$MultiNBack.getHighScore(undefined);

var initialState = {
config: initialConfig,
Expand All @@ -48,7 +48,7 @@ function reducer(state, action) {
}
var partiallyUpdatedState;
if (List.length(state.stateHistory) >= state.config.depth) {
var result = GameState$ReasonReactExamples.compareToHistory(state.answer, state.gameState, state.stateHistory, state.config);
var result = GameState$MultiNBack.compareToHistory(state.answer, state.gameState, state.stateHistory, state.config);
partiallyUpdatedState = result !== undefined ? ({
config: state.config,
configPanelOpen: state.configPanelOpen,
Expand All @@ -58,7 +58,7 @@ function reducer(state, action) {
tl: state.stateHistory
},
answer: state.answer,
score: Score$ReasonReactExamples.calculateScore(result, state.config.depth) + state.score | 0,
score: Score$MultiNBack.calculateScore(result, state.config.depth) + state.score | 0,
highScore: state.highScore
}) : ({
config: state.config,
Expand All @@ -67,7 +67,7 @@ function reducer(state, action) {
stateHistory: /* [] */0,
answer: state.answer,
score: 0,
highScore: Score$ReasonReactExamples.updateHighScore(state.score)
highScore: Score$MultiNBack.updateHighScore(state.score)
});
} else {
partiallyUpdatedState = {
Expand All @@ -86,17 +86,17 @@ function reducer(state, action) {
return {
config: partiallyUpdatedState.config,
configPanelOpen: partiallyUpdatedState.configPanelOpen,
gameState: GameState$ReasonReactExamples.makeRandom(state.config),
gameState: GameState$MultiNBack.makeRandom(state.config),
stateHistory: partiallyUpdatedState.stateHistory,
answer: Answer$ReasonReactExamples.make(undefined),
answer: Answer$MultiNBack.make(undefined),
score: partiallyUpdatedState.score,
highScore: partiallyUpdatedState.highScore
};
} else {
switch (action.TAG | 0) {
case /* UpdateDepthConfig */0 :
return {
config: GameConfiguration$ReasonReactExamples.updateDepth(action._0, state.config),
config: GameConfiguration$MultiNBack.updateDepth(action._0, state.config),
configPanelOpen: state.configPanelOpen,
gameState: state.gameState,
stateHistory: state.stateHistory,
Expand All @@ -106,7 +106,7 @@ function reducer(state, action) {
};
case /* UpdateModalityConfig */1 :
return {
config: GameConfiguration$ReasonReactExamples.updateModality(action._0, action._1, state.config),
config: GameConfiguration$MultiNBack.updateModality(action._0, action._1, state.config),
configPanelOpen: state.configPanelOpen,
gameState: state.gameState,
stateHistory: state.stateHistory,
Expand Down Expand Up @@ -142,20 +142,20 @@ function App(Props) {
className: "overviewContainer"
}, React.createElement("div", {
className: "scoreContainer"
}, value !== 0 ? React.createElement(Statistics$ReasonReactExamples.make, {
}, value !== 0 ? React.createElement(Statistics$MultiNBack.make, {
label: "Turn",
value: value + 1 | 0
}) : "First Turn!"), React.createElement("div", {
className: "scoreContainer"
}, value$1 !== 0 ? React.createElement(Statistics$ReasonReactExamples.make, {
}, value$1 !== 0 ? React.createElement(Statistics$MultiNBack.make, {
label: "Score",
value: value$1
}) : null), React.createElement("div", {
className: "scoreContainer"
}, value$2 !== undefined ? React.createElement(Statistics$ReasonReactExamples.make, {
}, value$2 !== undefined ? React.createElement(Statistics$MultiNBack.make, {
label: "High Score",
value: value$2
}) : null)), React.createElement(Canvas$ReasonReactExamples.make, {
}) : null)), React.createElement(Canvas$MultiNBack.make, {
config: state.config,
gameState: state.gameState
}), state.configPanelOpen ? null : React.createElement("div", {
Expand All @@ -170,7 +170,7 @@ function App(Props) {
onClick: (function (param) {
return Curry._1(dispatch, /* AdvanceTurn */1);
})
}, List.length(state.stateHistory) === 0 ? "Start" : "Next")), !state.configPanelOpen && List.length(state.stateHistory) === 0 ? React.createElement(ConfigurationTrigger$ReasonReactExamples.make, {
}, List.length(state.stateHistory) === 0 ? "Start" : "Next")), !state.configPanelOpen && List.length(state.stateHistory) === 0 ? React.createElement(ConfigurationTrigger$MultiNBack.make, {
toggleConfigPanelOpen: (function (param) {
return Curry._1(dispatch, /* ToggleConfigPanelOpen */0);
})
Expand All @@ -181,23 +181,23 @@ function App(Props) {
justifyContent: "center"
}
}, $$Array.map((function (modality) {
var match = Modality$ReasonReactExamples.getValue(modality, state.config.modalities);
var match = Modality$MultiNBack.getValue(modality, state.config.modalities);
if (match !== undefined) {
return React.createElement(AnswerToggle$ReasonReactExamples.make, {
checked: Modality$ReasonReactExamples.getValue(modality, state.answer),
return React.createElement(AnswerToggle$MultiNBack.make, {
checked: Modality$MultiNBack.getValue(modality, state.answer),
onChange: (function (param) {
return Curry._1(dispatch, {
TAG: /* UpdateAnswer */2,
_0: Answer$ReasonReactExamples.toggle(modality, state.answer)
_0: Answer$MultiNBack.toggle(modality, state.answer)
});
}),
label: "Same " + Modality$ReasonReactExamples.getLabel(modality),
key: Modality$ReasonReactExamples.getLabel(modality) + "_answer"
label: "Same " + Modality$MultiNBack.getLabel(modality),
key: Modality$MultiNBack.getLabel(modality) + "_answer"
});
} else {
return null;
}
}), Modality$ReasonReactExamples.allModalityTypes)) : null, React.createElement(ConfigurationPanel$ReasonReactExamples.make, {
}), Modality$MultiNBack.allModalityTypes)) : null, React.createElement(ConfigurationPanel$MultiNBack.make, {
panelOpen: state.configPanelOpen,
config: state.config,
updateModalityConfig: (function (modality, value) {
Expand Down
168 changes: 0 additions & 168 deletions src/App.re

This file was deleted.

Loading