Skip to content

Instantly share code, notes, and snippets.

@saschatimme
Created May 21, 2017 17:16
Show Gist options
  • Save saschatimme/9fc6a6091d6e51e64040dcbbdf2a5d1e to your computer and use it in GitHub Desktop.
Save saschatimme/9fc6a6091d6e51e64040dcbbdf2a5d1e to your computer and use it in GitHub Desktop.
module Experiment1 = {
type t =
| Disabled
| Control
| VarA
| VarB;
let equal a b =>
switch (a, b) {
| (Disabled, Disabled) => true
| (Control, Control) => true
| (VarA, VarA) => true
| (VarB, VarB) => true
| _ => false
};
let getVariant () => {
let variantIndex = Random.int 3;
switch variantIndex {
| 1 => Control
| 2 => VarA
| 3 => VarB
| _ => Disabled
}
};
};
module Experiment2 = {
type t =
| Disabled
| Control
| VarX
| VarY;
let equal a b =>
switch (a, b) {
| (Disabled, Disabled) => true
| (Control, Control) => true
| (VarX, VarX) => true
| (VarY, VarY) => true
| _ => false
};
let getVariant () => {
let variantIndex = Random.int 3;
switch variantIndex {
| 1 => Control
| 2 => VarX
| 3 => VarY
| _ => Disabled
}
};
};
let myExp = Experiment1.getVariant ();
let color =
if (Experiment1.equal myExp Experiment1.VarA) {
"blue"
} else {
"red"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment