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

View File

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

View File

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

View File

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

View File

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

View File

@ -86,12 +86,6 @@ module O = {
let min = compare((<)); let min = compare((<));
let max = 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 */ /* Functions */
@ -248,7 +242,7 @@ module A = {
let of_list = Array.of_list; let of_list = Array.of_list;
let length = Array.length; let length = Array.length;
let append = Array.append; let append = Array.append;
let empty = [||]; // let empty = [||];
let unsafe_get = Array.unsafe_get; let unsafe_get = Array.unsafe_get;
let get = Belt.Array.get; let get = Belt.Array.get;
let getBy = Belt.Array.getBy; let getBy = Belt.Array.getBy;
@ -471,6 +465,3 @@ module JsArray = {
); );
let filter = Js.Array.filter; 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} |> ReasonReact.array}
<div className="bg-green-100 p-2 rounded-sm mt-6 text-lg"> <div className="bg-green-100 p-2 rounded-sm mt-6 text-lg">
{model.run(Prop.Combo.InputValues.toValueArray(formState.combo)) {model.run(Prop.Combo.InputValues.toValueArray(formState.combo))
|> E.O.React.fmapOrNull(propValue)} |> R.O.fmapOrNull(propValue)}
</div> </div>
</div> </div>
</div>; </div>;

View File

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

3084
yarn.lock

File diff suppressed because it is too large Load Diff