diff --git a/src/lib/Prop.re b/src/lib/Prop.re
index 768f9526..46f6dd17 100644
--- a/src/lib/Prop.re
+++ b/src/lib/Prop.re
@@ -1,14 +1,25 @@
module Value = {
+ type binaryConditional =
+ | Selected(bool)
+ | Unselected;
type t =
+ | BinaryConditional(binaryConditional)
| SelectSingle(string)
| DateTime(MomentRe.Moment.t)
| FloatPoint(float)
+ | Probability(float)
| FloatCdf(string);
let to_string = (t: t) => {
switch (t) {
+ | BinaryConditional(binaryConditional) =>
+ switch (binaryConditional) {
+ | Selected(r) => r ? "True" : "False"
+ | Unselected => ""
+ }
| SelectSingle(r) => r
| FloatCdf(r) => r
+ | Probability(r) => (r *. 100. |> Js.Float.toFixed) ++ "%"
| DateTime(r) => r |> MomentRe.Moment.defaultFormat
| FloatPoint(r) => r |> Js.Float.toFixed
};
@@ -34,17 +45,23 @@ module Type = {
max: option('a),
};
+ type withDefault('a) = {default: option('a)};
+
type t =
+ | BinaryConditional
| SelectSingle(selectSingle)
| FloatPoint(withDefaultMinMax(float))
+ | Probability(withDefault(float))
| DateTime(withDefaultMinMax(MomentRe.Moment.t))
| Year(withDefaultMinMax(float))
| FloatCdf;
let default = (t: t) =>
switch (t) {
+ | BinaryConditional => Some(Value.BinaryConditional(Unselected))
| 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))
| DateTime(r) => r.default->Belt.Option.map(p => Value.DateTime(p))
| SelectSingle(r) =>
r.default->Belt.Option.map(p => Value.SelectSingle(p))
diff --git a/src/lib/ValueForm.re b/src/lib/ValueForm.re
index b3983392..89a0e812 100644
--- a/src/lib/ValueForm.re
+++ b/src/lib/ValueForm.re
@@ -33,6 +33,36 @@ let make =
}
)}
/>
+ | (BinaryConditional, Some(BinaryConditional(r))) =>
+ switch (r) {
+ | Unselected =>
+
onChange(Some(BinaryConditional(Selected(true))))}>
+ {"Select" |> ReasonReact.string}
+
+ | Selected(true) =>
+
+ {"YES!" |> ReasonReact.string}
+
onChange(Some(BinaryConditional(Selected(false))))}>
+ {"No" |> ReasonReact.string}
+
+
onChange(Some(BinaryConditional(Unselected)))}>
+ {"Deselect" |> ReasonReact.string}
+
+
+ | Selected(false) =>
+
+ {"NO!" |> ReasonReact.string}
+
onChange(Some(BinaryConditional(Selected(true))))}>
+ {"Yes" |> ReasonReact.string}
+
+
onChange(Some(BinaryConditional(Unselected)))}>
+ {"Deselect" |> ReasonReact.string}
+
+
+ }
| (Year(_), _)
| (FloatPoint(_), _) =>
| (SelectSingle(t), Some(SelectSingle(r))) =>
diff --git a/src/models/EAFunds.re b/src/models/EAFunds.re
index 368311d6..75b44750 100644
--- a/src/models/EAFunds.re
+++ b/src/models/EAFunds.re
@@ -11,8 +11,12 @@ module Data = {
type output =
| DONATIONS
+ | CHANCE_OF_EXISTENCE
| PAYOUTS;
+ type conditionals =
+ | WORLD_CATASTROPHE;
+
type fundWithInfo = {
group,
name: string,
@@ -93,6 +97,7 @@ module Model = {
| (Fund(META), DONATIONS) => 9300000.0
| (Fund(META), PAYOUTS) => 830000.0
| (All, _) => sum()
+ | (_, CHANCE_OF_EXISTENCE) => 0.0
};
};
let make =
@@ -102,14 +107,21 @@ module Model = {
currentDateTime: MomentRe.Moment.t,
output: output,
) => {
- Prop.Value.FloatCdf(
- calculateDifference(
- currentValue(group, output),
- dateTime,
- currentDateTime,
- yearlyMeanGrowthRateIfNotClosed(group),
- ),
- );
+ switch (output) {
+ | DONATIONS
+ | PAYOUTS =>
+ Prop.Value.FloatCdf(
+ calculateDifference(
+ currentValue(group, output),
+ dateTime,
+ currentDateTime,
+ yearlyMeanGrowthRateIfNotClosed(group),
+ ),
+ )
+ | CHANCE_OF_EXISTENCE =>
+ let yearDiff = MomentRe.diff(dateTime, currentDateTime, `days) /. 365.;
+ Prop.Value.Probability((100. -. yearDiff) /. 100.);
+ };
};
};
@@ -126,6 +138,7 @@ module Interface = {
let outputFromString = (s: string) =>
switch (s) {
| "donations" => DONATIONS
+ | "exists" => CHANCE_OF_EXISTENCE
| _ => PAYOUTS
};
@@ -136,6 +149,7 @@ module Interface = {
Some(DateTime(intendedYear)),
Some(DateTime(currentYear)),
Some(SelectSingle(output)),
+ Some(BinaryConditional(r)),
|] =>
choiceFromString(fund)
|> E.O.fmap(fund =>
@@ -206,12 +220,19 @@ module Interface = {
SelectSingle({
default: Some("Output"),
options: [
- {name: "Donations", id: "donations"},
- {name: "Funding", id: "funding"},
+ {name: "Donations | Exists", id: "donations"},
+ {name: "Funding | Exists", id: "funding"},
+ {name: "Exists", id: "exists"},
],
}),
(),
),
+ TypeWithMetadata.make(
+ ~name="Conditional on World Ending",
+ ~id="worldEnd",
+ ~type_=BinaryConditional,
+ (),
+ ),
|],
outputTypes: [||],
run,