Last active
May 9, 2017 17:31
-
-
Save wokalski/b94e6ffabc7c0cd0ec61b1a63b711800 to your computer and use it in GitHub Desktop.
Very sad OCaml module situation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; | |
}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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