1

What is the meaning of the '#' in the following signature?

val insertBefore : #node Js.t -> #node Js.t -> #node Js.t Js.opt -> unit
Antoine
  • 1,782
  • 1
  • 14
  • 32

1 Answers1

4

See the #-types section of the OCaml reference manual (http://caml.inria.fr/pub/docs/manual-ocaml/types.html).

A function type #node -> t takes an object of class node or its subclass and returns t.

For example,

class c = object method x = 1 end

let g : #c -> int = fun o -> o#x

Function g can take an object of class c or its subclass. #c is an abbreviation of < x : int; ..> therefore,

let h = (g : < x : int; ..> -> int)

is type-checked.

tbrk
  • 1,290
  • 1
  • 13
  • 20
camlspotter
  • 8,990
  • 23
  • 27