Skip to content

Instantly share code, notes, and snippets.

@linktohack
Created July 4, 2018 14:29
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 linktohack/7eb131c52f35af4e9429d7b3d17a59c3 to your computer and use it in GitHub Desktop.
Save linktohack/7eb131c52f35af4e9429d7b3d17a59c3 to your computer and use it in GitHub Desktop.
REASONML Two modules
module Sig =
struct
module type NoteSig = sig type t end
module type TodoSig = sig type t end
end
module Same =
struct
module rec Note:Sig.NoteSig = struct type t = {
todo: Todo.t;} end
and Todo:Sig.TodoSig = struct type t = {
notes: Note.t array;} end
end
module A =
struct module Note(T:Sig.TodoSig) = struct type t = {
todo: T.t;} end end
module B =
struct
module Todo(N:Sig.NoteSig) = struct type t = {
notes: N.t array;} end
end
module C =
struct
module rec NoteImpl:Sig.NoteSig = A.Note(TodoImpl)
and TodoImpl:Sig.TodoSig = B.Todo(NoteImpl)
end
let todo1: Same.Todo.t = { notes = [||] }
let todo2: C.TodoImpl.t = { notes = [||] }
@linktohack
Copy link
Author

Here is the error

  33 │
  34 │ /* impl */
  35 │ let todo1: Same.Todo.t = {notes: [||]};
  36 │ let todo2: C.TodoImpl.t = {notes: [||]};
  37 │ Js.log2(todo1, todo2);

  The record field notes can't be found.

  If it's defined in another module or file, bring it into scope by:
  - Annotating it with said module name: let baby = {MyModule.age: 3}
  - Or specifying its type: let baby: MyModule.person = {age: 3}

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