Upgraded bucklescript

This commit is contained in:
Ozzie Gooen 2020-04-30 13:30:52 +01:00
parent 2ab2faf5e9
commit 0d4c71190d
11 changed files with 1910 additions and 1308 deletions

View File

@ -26,9 +26,9 @@
"author": "",
"license": "MIT",
"dependencies": {
"@foretold/components": "0.0.3",
"@foretold/guesstimator": "1.0.10",
"@glennsl/bs-jest": "^0.5.0",
"@foretold/components": "0.0.6",
"@foretold/guesstimator": "1.0.11",
"@glennsl/bs-jest": "^0.5.1",
"@glennsl/bs-json": "^5.0.2",
"antd": "3.17.0",
"autoprefixer": "9.7.4",
@ -37,12 +37,12 @@
"bs-ant-design-alt": "2.0.0-alpha.33",
"bs-css": "11.0.0",
"bs-moment": "0.4.4",
"bs-platform": "7.0.1",
"bs-platform": "7.2.2",
"bs-reform": "9.7.1",
"bsb-js": "1.1.7",
"d3": "5.15.0",
"gh-pages": "2.2.0",
"jest": "^25.1.0",
"jest": "^25.5.1",
"jstat": "1.9.2",
"lenses-ppx": "5.1.0",
"less": "3.10.3",

View File

@ -20,7 +20,7 @@ let setup = dist =>
RenderTypes.DistPlusRenderer.make(~distPlusIngredients=dist,())
|> DistPlusRenderer.run
|> RenderTypes.DistPlusRenderer.Outputs.distplus
|> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />);
|> R.O.fmapOrNull(distPlus => <DistPlusPlot distPlus />);
let simpleExample = (name, guesstimatorString) =>
<>

View File

@ -69,15 +69,15 @@ module Menu = {
[@react.component]
let make = () => {
<div className=Styles.menu>
<Item href={routeToPath(Home)} key="home"> {"Home" |> E.ste} </Item>
<Item href={routeToPath(Home)} key="home"> {"Home" |> R.ste} </Item>
<Item href={routeToPath(DistBuilder)} key="dist-builder">
{"Dist Builder" |> E.ste}
{"Dist Builder" |> R.ste}
</Item>
<Item href={routeToPath(DistBuilder2)} key="dist-builder-2">
{"Dist Builder 2" |> E.ste}
{"Dist Builder 2" |> R.ste}
</Item>
<Item href={routeToPath(DistBuilder3)} key="dist-builder-3">
{"Dist Builder 3" |> E.ste}
{"Dist Builder 3" |> R.ste}
</Item>
</div>;
};
@ -103,13 +103,13 @@ let make = () => {
| Model(id) =>
switch (Models.getById(id)) {
| Some(model) => <FormBuilder.ModelForm model key=id />
| None => <div> {"Page is not found" |> E.ste} </div>
| None => <div> {"Page is not found" |> R.ste} </div>
}
| DistBuilder => <DistBuilder />
| DistBuilder2 => <DistBuilder2 />
| DistBuilder3 => <DistBuilder3 />
| Home => <Home />
| _ => <div> {"Page is not found" |> E.ste} </div>
| _ => <div> {"Page is not found" |> R.ste} </div>
}}
</div>;
};

9
src/R.re Normal file
View File

@ -0,0 +1,9 @@
let ste = React.string;
let showIf = (cond, comp) => cond ? comp : ReasonReact.null;
module O = {
let defaultNull = E.O.default(ReasonReact.null);
let fmapOrNull = (fn, el) => el |> E.O.fmap(fn) |> E.O.default(ReasonReact.null);
let flatten = E.O.default(ReasonReact.null);
};

View File

@ -39,7 +39,7 @@ module FieldString = {
<Form.Field
field
render={({handleChange, error, value, validate}) =>
<Antd.Form.Item label={label |> E.ste}>
<Antd.Form.Item label={label |> R.ste}>
<Antd.Input
value
onChange={BsReform.Helpers.handleChange(handleChange)}
@ -57,7 +57,7 @@ module FieldFloat = {
<Form.Field
field
render={({handleChange, error, value, validate}) =>
<Antd.Form.Item label={label |> E.ste}>
<Antd.Form.Item label={label |> R.ste}>
<Antd.Input
value
onChange={BsReform.Helpers.handleChange(handleChange)}
@ -121,7 +121,7 @@ type inputs = {
module DemoDist = {
[@react.component]
let make = (~guesstimatorString, ~domain, ~unit, ~options) => {
<Antd.Card title={"Distribution" |> E.ste}>
<Antd.Card title={"Distribution" |> R.ste}>
<div className=Styles.spacer />
<div>
{switch (domain, unit, options) {
@ -151,11 +151,11 @@ module DemoDist = {
| Some(distPlus) => <DistPlusPlot distPlus />
| _ =>
"Correct Guesstimator string input to show a distribution."
|> E.ste
|> R.ste
};
| _ =>
"Nothing to show. Try to change the distribution description."
|> E.ste
|> R.ste
}}
</div>
</Antd.Card>;
@ -302,7 +302,7 @@ let make = () => {
demoDist
<div className=Styles.spacer />
<Antd.Card
title={"Distribution Form" |> E.ste}
title={"Distribution Form" |> R.ste}
extra={
<Antd.Button
icon=Antd.IconName.reload
@ -325,19 +325,19 @@ let make = () => {
<Form.Field
field=FormConfig.DomainType
render={({handleChange, value}) =>
<Antd.Form.Item label={"Domain Type" |> E.ste}>
<Antd.Form.Item label={"Domain Type" |> R.ste}>
<Antd.Select value onChange={e => e |> handleChange}>
<Antd.Select.Option value="Complete">
{"Complete" |> E.ste}
{"Complete" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="LeftLimited">
{"Left Limited" |> E.ste}
{"Left Limited" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="RightLimited">
{"Right Limited" |> E.ste}
{"Right Limited" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="LeftAndRightLimited">
{"Left And Right Limited" |> E.ste}
{"Left And Right Limited" |> R.ste}
</Antd.Select.Option>
</Antd.Select>
</Antd.Form.Item>
@ -360,7 +360,7 @@ let make = () => {
/>
</Col>
</>
|> E.showIf(
|> R.showIf(
E.L.contains(
reform.state.values.domainType,
["LeftLimited", "LeftAndRightLimited"],
@ -382,7 +382,7 @@ let make = () => {
/>
</Col>
</>
|> E.showIf(
|> R.showIf(
E.L.contains(
reform.state.values.domainType,
["RightLimited", "LeftAndRightLimited"],
@ -394,13 +394,13 @@ let make = () => {
<Form.Field
field=FormConfig.UnitType
render={({handleChange, value}) =>
<Antd.Form.Item label={"Unit Type" |> E.ste}>
<Antd.Form.Item label={"Unit Type" |> R.ste}>
<Antd.Select value onChange={e => e |> handleChange}>
<Antd.Select.Option value="UnspecifiedDistribution">
{"Unspecified Distribution" |> E.ste}
{"Unspecified Distribution" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="TimeDistribution">
{"Time Distribution" |> E.ste}
{"Time Distribution" |> R.ste}
</Antd.Select.Option>
</Antd.Select>
</Antd.Form.Item>
@ -412,7 +412,7 @@ let make = () => {
<Form.Field
field=FormConfig.Zero
render={({handleChange, value}) =>
<Antd.Form.Item label={"Zero Point" |> E.ste}>
<Antd.Form.Item label={"Zero Point" |> R.ste}>
<Antd_DatePicker
value
onChange={e => {
@ -428,34 +428,34 @@ let make = () => {
<Form.Field
field=FormConfig.Unit
render={({handleChange, value}) =>
<Antd.Form.Item label={"Unit" |> E.ste}>
<Antd.Form.Item label={"Unit" |> R.ste}>
<Antd.Select value onChange={e => e |> handleChange}>
<Antd.Select.Option value="days">
{"Days" |> E.ste}
{"Days" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="hours">
{"Hours" |> E.ste}
{"Hours" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="milliseconds">
{"Milliseconds" |> E.ste}
{"Milliseconds" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="minutes">
{"Minutes" |> E.ste}
{"Minutes" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="months">
{"Months" |> E.ste}
{"Months" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="quarters">
{"Quarters" |> E.ste}
{"Quarters" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="seconds">
{"Seconds" |> E.ste}
{"Seconds" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="weeks">
{"Weeks" |> E.ste}
{"Weeks" |> R.ste}
</Antd.Select.Option>
<Antd.Select.Option value="years">
{"Years" |> E.ste}
{"Years" |> R.ste}
</Antd.Select.Option>
</Antd.Select>
</Antd.Form.Item>
@ -463,7 +463,7 @@ let make = () => {
/>
</Col>
</>
|> E.showIf(
|> R.showIf(
E.L.contains(
reform.state.values.unitType,
["TimeDistribution"],
@ -489,7 +489,7 @@ let make = () => {
</Row>
<Antd.Button
_type=`primary icon=Antd.IconName.reload onClick=onRealod>
{"Update Distribution" |> E.ste}
{"Update Distribution" |> R.ste}
</Antd.Button>
</Antd.Form>
</Form.Provider>

View File

@ -13,7 +13,7 @@ module FieldString = {
<Form.Field
field
render={({handleChange, error, value, validate}) =>
<Antd.Form.Item label={label |> E.ste}>
<Antd.Form.Item label={label |> R.ste}>
<Antd.Input
value
onChange={BsReform.Helpers.handleChange(handleChange)}
@ -38,7 +38,7 @@ module DemoDist = {
DistEditor.getPdfFromUserInput(guesstimatorString);
let inside =
isEmpty
? "Nothing to show" |> E.ste
? "Nothing to show" |> R.ste
: {
let distPlus =
Distributions.DistPlus.make(
@ -54,7 +54,7 @@ module DemoDist = {
|> Distributions.DistPlus.T.scaleToIntegralSum(~intendedSum=1.0);
<DistPlusPlot distPlus />;
};
<Antd.Card title={"Distribution" |> E.ste}>
<Antd.Card title={"Distribution" |> R.ste}>
<div className=Styles.spacer />
inside
</Antd.Card>;
@ -86,7 +86,7 @@ let make = () => {
<div className=Styles.spacer />
demoDist
<div className=Styles.spacer />
<Antd.Card title={"Distribution Form" |> E.ste}>
<Antd.Card title={"Distribution Form" |> R.ste}>
<Form.Provider value=reform>
<Antd.Form>
<Row _type=`flex>

View File

@ -13,7 +13,7 @@ module FieldString = {
<Form.Field
field
render={({handleChange, error, value, validate}) =>
<Antd.Form.Item label={label |> E.ste}>
<Antd.Form.Item label={label |> R.ste}>
<Antd.Input
value
onChange={BsReform.Helpers.handleChange(handleChange)}
@ -62,7 +62,7 @@ module DemoDist = {
<DistPlusPlot distPlus />;
})
|> E.O.default(ReasonReact.null);
<Antd.Card title={"Distribution" |> E.ste}>
<Antd.Card title={"Distribution" |> R.ste}>
<div className=Styles.spacer />
inside
{str |> ReasonReact.string}
@ -95,7 +95,7 @@ let make = () => {
<div className=Styles.spacer />
demoDist
<div className=Styles.spacer />
<Antd.Card title={"Distribution Form" |> E.ste}>
<Antd.Card title={"Distribution Form" |> R.ste}>
<Form.Provider value=reform>
<Antd.Form>
<Row _type=`flex>

View File

@ -86,12 +86,6 @@ module O = {
let min = compare((<));
let max = compare((>));
module React = {
let defaultNull = default(ReasonReact.null);
let fmapOrNull = fn => fmap(fn) ||> default(ReasonReact.null);
let flatten = default(ReasonReact.null);
};
};
/* Functions */
@ -248,7 +242,7 @@ module A = {
let of_list = Array.of_list;
let length = Array.length;
let append = Array.append;
let empty = [||];
// let empty = [||];
let unsafe_get = Array.unsafe_get;
let get = Belt.Array.get;
let getBy = Belt.Array.getBy;
@ -471,6 +465,3 @@ module JsArray = {
);
let filter = Js.Array.filter;
};
let ste = React.string;
let showIf = (cond, comp) => cond ? comp : ReasonReact.null;

View File

@ -100,7 +100,7 @@ module ModelForm = {
|> ReasonReact.array}
<div className="bg-green-100 p-2 rounded-sm mt-6 text-lg">
{model.run(Prop.Combo.InputValues.toValueArray(formState.combo))
|> E.O.React.fmapOrNull(propValue)}
|> R.O.fmapOrNull(propValue)}
</div>
</div>
</div>;

View File

@ -45,9 +45,9 @@ module Table = {
</a>
</div>
<div className={TableStyles.col(~f=3.0, ())}>
{model.description |> E.ste}
{model.description |> R.ste}
</div>
<div className={TableStyles.col()}> {model.author |> E.ste} </div>
<div className={TableStyles.col()}> {model.author |> R.ste} </div>
</div>;
};
};
@ -56,11 +56,11 @@ module Table = {
[@react.component]
let make = () => {
<div className=TableStyles.row>
<div className={TableStyles.col()}> {"Name" |> E.ste} </div>
<div className={TableStyles.col()}> {"Name" |> R.ste} </div>
<div className={TableStyles.col(~f=3.0, ())}>
{"Description" |> E.ste}
{"Description" |> R.ste}
</div>
<div className={TableStyles.col()}> {"Author" |> E.ste} </div>
<div className={TableStyles.col()}> {"Author" |> R.ste} </div>
</div>;
};
};
@ -68,11 +68,11 @@ module Table = {
[@react.component]
let make = () => {
<>
<h3 className=Styles.h3> {"Probability Models" |> E.ste} </h3>
<h3 className=Styles.h3> {"Probability Models" |> R.ste} </h3>
<ColumnsTitles />
{Models.all
|> E.A.fmap((model: Prop.Model.t) => {
<Item model key={model.id}> {model.name |> E.ste} </Item>
<Item model key={model.id}> {model.name |> R.ste} </Item>
})
|> ReasonReact.array}
</>;

3084
yarn.lock

File diff suppressed because it is too large Load Diff