The following session is run using the iocamljs min kernel compiled using a 32 bit OCaml toolchain on a 64 bit host given here. The final js_of_ocaml compilation step is done with a 64 bit version of the js_of_ocaml compiler due to a problem with the 32 bit version.
I have also been able to run the following to the same extent with a full 64 bit build, however, that requires various patches to bin_prot (32 bit bit patterns like 0x8000_0000 get marshalled in the .cmo/a files as 64 bit constants, which cannot be unmarshalled by js_of_ocaml - replacing them with code like 1 lsl 31 fixes it but it's a kludge).
In [1]:
#use "topfind"
In [2]:
#require "unix,bigarray,dynlink,type_conv"
In [3]:
#require "bin_prot"
In [4]:
#require "variantslib,sexplib"
In [5]:
#require "fieldslib,pa_bench,oUnit,pa_ounit"
In [6]:
#require "typerep_lib"
In [7]:
#require "core_kernel"
So typerep_lib fails to load with a javascript exception which in turn stops core_kernel from loading.
from _build/_log
ocamlfind ocamlc -pack -g
lib/named_intf.cmo
lib/type_equal.cmo
lib/typename.cmo
lib/variant_and_record_intf.cmo
lib/std_internal.cmo
lib/make_typename.cmo
lib/typerepable.cmo
lib/type_abstract.cmo
lib/type_generic_intf.cmo
lib/type_generic.cmo
lib/typerep_obj.cmo
lib/std.cmo
-o lib/typerep_lib.cmo
Try loading each of the .cmo files one at a time to find the bad module.
In [1]:
#directory "/home/andyman/dev/github/forks/typerep/_build/lib"
In [2]:
#load "named_intf.cmo"
In [5]:
#load "type_equal.cmo"
In [6]:
Type_equal.conv
Out[6]:
In [7]:
#load "typename.cmo"
In [8]:
#load "variant_and_record_intf.cmo"
In [9]:
#load "std_internal.cmo"
So our problems start in std_internal.cmo.
In [ ]:
#load "make_typename.cmo"
In [ ]:
#load "typerepable.cmo"
In [ ]:
#load "type_abstract.cmo"
In [ ]:
#load "type_generic_intf.cmo"
In [ ]:
#load "type_generic.cmo"
In [ ]:
#load "typerep_obj.cmo"
In [ ]:
#load "std.cmo"
My suspicion is it is the recursive module defined in std_internal. Lets have a play.
In [25]:
module Typename = struct
type 'a t
end
module Type_equal = struct
type ('a,'b) t
end
module rec Typerep : sig
type _ t =
| Int : int t
| Int32 : int32 t
| Int64 : int64 t
| Nativeint : nativeint t
| Char : char t
| Float : float t
| String : string t
| Bool : bool t
| Unit : unit t
| Option : 'a t -> 'a option t
| List : 'a t -> 'a list t
| Array : 'a t -> 'a array t
| Lazy : 'a t -> 'a Lazy.t t
| Ref : 'a t -> 'a ref t
(*| Function : ('dom t * 'rng t) -> ('dom -> 'rng) t
| Tuple : 'a Typerep.Tuple.t -> 'a t
| Record : 'a Typerep.Record.t -> 'a t
| Variant : 'a Typerep.Variant.t -> 'a t
| Named : ('a Typerep.Named.t * 'a t Lazy.t option) -> 'a t*)
module Named : sig
module type T0 = sig
type named
type t
val typename_of_named : named Typename.t
val typename_of_t : t Typename.t
val witness : (t, named) Type_equal.t
end
type 'a t = T0 of (module T0 with type t = 'a)
val arity : _ t -> int
end
end = struct
type _ t =
| Int : int t
| Int32 : int32 t
| Int64 : int64 t
| Nativeint : nativeint t
| Char : char t
| Float : float t
| String : string t
| Bool : bool t
| Unit : unit t
| Option : 'a t -> 'a option t
| List : 'a t -> 'a list t
| Array : 'a t -> 'a array t
| Lazy : 'a t -> 'a Lazy.t t
| Ref : 'a t -> 'a ref t
(*| Function : ('dom t * 'rng t) -> ('dom -> 'rng) t
| Tuple : 'a Typerep.Tuple.t -> 'a t
| Record : 'a Typerep.Record.t -> 'a t
| Variant : 'a Typerep.Variant.t -> 'a t
| Named : ('a Typerep.Named.t * 'a t Lazy.t option) -> 'a t*)
module Named = struct
module type T0 = sig
type named
type t
val typename_of_named : named Typename.t
val typename_of_t : t Typename.t
val witness : (t, named) Type_equal.t
end
type 'a t = T0 of (module T0 with type t = 'a)
let arity = function T0 _ -> 0
end
end
Out[25]:
Out[25]:
Out[25]:
The error comes with the addition of the arity function.
Lets try to simplify a bit.
In [2]:
module rec Typerep : sig
module Named : sig
module type T0 = sig
type named
type t
end
type 'a t = T0 of (module T0 with type t = 'a)
val arity : _ t -> int
end
end = struct
module Named = struct
module type T0 = sig
type named
type t
end
type 'a t = T0 of (module T0 with type t = 'a)
let arity = function T0 _ -> 0
end
end
Out[2]:
Remove the rec
In [4]:
module Typerep : sig
module Named : sig
module type T0 = sig
type named
type t
end
type 'a t = T0 of (module T0 with type t = 'a)
val arity : _ t -> int
end
end = struct
module Named = struct
module type T0 = sig
type named
type t
end
type 'a t = T0 of (module T0 with type t = 'a)
let arity = function T0 _ -> 0
end
end
Out[4]:
In [1]:
open Core_kernel.Std
In [2]:
Array.map
Out[2]:
In [3]:
String.hash "hello"
Out[3]:
In [4]:
Float.hash 1.
Out[4]:
In [ ]: