Skip to content

Instantly share code, notes, and snippets.

@wokalski
Last active May 9, 2017 17:31
Show Gist options
  • Save wokalski/b94e6ffabc7c0cd0ec61b1a63b711800 to your computer and use it in GitHub Desktop.
Save wokalski/b94e6ffabc7c0cd0ec61b1a63b711800 to your computer and use it in GitHub Desktop.
Very sad OCaml module situation
/* Problem1 */
module Y = {
/* Why is this include needed? */
include File2.Common;
type item = {x: string};
let renderItem x => x.item.x;
};
module MyList = File2.CreateComponent2 Y;
module Test = {
type x = {
abc: string
};
};
/* Cannot use a type from another module */
module Z = {
include File2.Common;
type item = Test.x;
/* this works:
type x = {
abc: string
};
*/
let renderItem x => x.item.abc;
};
module MyList2 = File2.CreateComponent2 Z;
/* Bonus case - why? */
module MyList3 = File2.CreateComponent2 {
include File2.Common;
type item = { abc: string };
let renderItem x => x.item.abc;
};
module Common = {
type section 'a = {data: 'a};
type renderBag 'a = {item: 'a};
};
module type Impl = {type item; let renderItem: Common.renderBag item => string;};
module CreateComponent (Impl: Impl) => {
let createRenderBag ::item => item;
};
module CreateComponent2 (Impl: Impl) => {
/* Why is this include needed? */
include Common;
type b = Common.section Impl.item;
let createElement sections::(sections: array b) =>
Array.map (fun x => {"data": x.data}) sections;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment