Skip to content

Instantly share code, notes, and snippets.

@jaredly
Created August 23, 2016 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredly/432e244c5ac0121862348e6d720b34c6 to your computer and use it in GitHub Desktop.
Save jaredly/432e244c5ac0121862348e6d720b34c6 to your computer and use it in GitHub Desktop.
type something = | Something 'a :something;
module type ChildType = {let makeSomething: int => something;};
let module MakeThing (ChildA: ChildType) (ChildB: ChildType) => {
type childArg = | A int | B int;
let doThing arg =>
switch arg {
| A n => ChildA.makeSomething 10
| B n => ChildB.makeSomething 5
};
};
let module Result =
(MakeThing
{ let makeSomething _ => Something "string"; }
{ let makeSomething _ => Something "otherSTring"; });
let x = Result.doThing (Result.A 10);
switch x {
| Something z => print_endline z
};
@jaredly
Copy link
Author

jaredly commented Aug 23, 2016

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment