From 7393f88bfde7e57ce285143518d8dc119930102f Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Sat, 8 Feb 2020 17:48:35 +0000 Subject: [PATCH] First attempt at Model type --- src/Model.re | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/Model.re diff --git a/src/Model.re b/src/Model.re new file mode 100644 index 00000000..ae3f8434 --- /dev/null +++ b/src/Model.re @@ -0,0 +1,68 @@ +module IOTypes = { + type singleChoice = {options: list(string)}; + type floatPoint = {validatations: list(float => bool)}; + type withDefault('a) = {default: option('a)}; +}; + +module Input = { + type parameterType = + | Year(IOTypes.withDefault(float)) + | SingleChoice(IOTypes.singleChoice) + | FloatPoint + | FloatCdf; + + type parameter = { + name: string, + parameterType, + }; + + let make = (name, parameterType) => {name, parameterType}; +}; + +module Output = { + type parameterType = + | Year + | SingleChoice(IOTypes.singleChoice) + | FloatPoint + | FloatCdf; + + type parameter = { + name: string, + parameterType, + }; + + let make = (name, parameterType) => {name, parameterType}; +}; + +type props = { + name: string, + author: string, + assumptions: list(Input.parameter), + inputs: list(Input.parameter), + outputs: list(Output.parameter), +}; + +let model1 = { + name: "Calculate the payments and payouts of EA Funds based on existing data.", + author: "George Harrison", + assumptions: [Input.make("Yearly Growth Rate", FloatPoint)], + inputs: [ + Input.make( + "Fund", + SingleChoice({ + options: [ + "Animal Welfare Fund", + "Global Health Fund", + "Long Term Future Fund", + "Meta Fund", + "Total", + ], + }), + ), + {name: "Year", parameterType: Year({default: Some(2030.0)})}, + ], + outputs: [ + Output.make("Payments", FloatCdf), + Output.make("Payouts", FloatCdf), + ], +}; \ No newline at end of file