diff --git a/src/lib/Prop.re b/src/lib/Prop.re index 8297864e..e55aefda 100644 --- a/src/lib/Prop.re +++ b/src/lib/Prop.re @@ -2,12 +2,20 @@ module Value = { type binaryConditional = | Selected(bool) | Unselected; + + type conditional = { + statement: string, + truthValue: bool, + }; + type t = | BinaryConditional(binaryConditional) | SelectSingle(string) | DateTime(MomentRe.Moment.t) | FloatPoint(float) | Probability(float) + | Conditional(conditional) + | ConditionalArray(array(conditional)) | FloatCdf(string); let to_string = (t: t) => { @@ -36,6 +44,8 @@ module Value = { ) |> ReasonReact.string | SelectSingle(r) => r |> ReasonReact.string + | ConditionalArray(r) => "Array" |> ReasonReact.string + | Conditional(r) => r.statement |> ReasonReact.string | FloatCdf(r) => let cdf: Types.distribution = CdfLibrary.Distribution.fromString(r, 2000); @@ -65,6 +75,16 @@ module Type = { default: option(string), }; + type conditionals = { + defaults: array(Value.conditional), + options: array(string), + }; + + let makeConditionals = (defaults, options): conditionals => { + defaults, + options, + }; + type floatPoint = {validatations: list(float => bool)}; type withDefaultMinMax('a) = { @@ -82,11 +102,13 @@ module Type = { | Probability(withDefault(float)) | DateTime(withDefaultMinMax(MomentRe.Moment.t)) | Year(withDefaultMinMax(float)) + | Conditionals(conditionals) | FloatCdf; let default = (t: t) => switch (t) { | BinaryConditional => Some(Value.BinaryConditional(Unselected)) + | Conditionals(s) => Some(Value.ConditionalArray(s.defaults)) | Year(r) => r.default->Belt.Option.map(p => Value.FloatPoint(p)) | FloatPoint(r) => r.default->Belt.Option.map(p => Value.FloatPoint(p)) | Probability(r) => r.default->Belt.Option.map(p => Value.Probability(p)) diff --git a/src/lib/ValueForm.re b/src/lib/ValueForm.re index 89a0e812..ceaf9d00 100644 --- a/src/lib/ValueForm.re +++ b/src/lib/ValueForm.re @@ -11,6 +11,7 @@ let make = ~onChange: onChange, ) => { switch (type_.type_, value) { + | (Conditionals(_), r) => "sdfsdf" |> ReasonReact.string | (Year(_), Some(FloatPoint(r))) => choiceFromString(fund) |> E.O.fmap(fund => @@ -230,14 +229,16 @@ module Interface = { }), (), ), - TypeWithMetadata.make( - ~name="Conditional on World Ending", - ~id="worldEnd", - ~type_=BinaryConditional, - (), - ), |], outputTypes: [||], run, }; -}; \ No newline at end of file +} /* )*/; +// TypeWithMetadata.make( +// ~name="Conditional on World Ending", +// ~id="worldEnd", +// ~type_= +// Conditionals( +// Prop.Type.makeConditionals([||], [|"Foo", "Bar", "Char"|]), +// ), +// (), \ No newline at end of file diff --git a/src/models/GlobalCatastrophe.re b/src/models/GlobalCatastrophe.re index 6c843644..7487959d 100644 --- a/src/models/GlobalCatastrophe.re +++ b/src/models/GlobalCatastrophe.re @@ -1,4 +1,9 @@ module Model = { + let foo = { + let bar = 2.0; + (); + }; + let make = (dateTime: MomentRe.Moment.t, currentDateTime: MomentRe.Moment.t) => { let yearDiff = MomentRe.diff(dateTime, currentDateTime, `days) /. 365.; Prop.Value.Probability(0.001 *. yearDiff);