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).
#use "topfind"
- : unit = () Findlib has been successfully loaded. Additional directives: #require "package";; to load a package #list;; to list the available packages #camlp4o;; to load camlp4 (standard syntax) #camlp4r;; to load camlp4 (revised syntax) #predicates "p,q,...";; to set these predicates Topfind.reset();; to force that packages will be reloaded #thread;; to enable threads - : unit = ()
#require "unix,bigarray,dynlink,type_conv"
/home/andyman/.opam/4.01.0+32bit/lib/ocaml/unix.cma: loaded /home/andyman/.opam/4.01.0+32bit/lib/ocaml/bigarray.cma: loaded /home/andyman/.opam/4.01.0+32bit/lib/ocaml/dynlink.cma: loaded /home/andyman/.opam/4.01.0+32bit/lib/ocaml/camlp4: added to search path /home/andyman/.opam/4.01.0+32bit/lib/type_conv: added to search path
#require "bin_prot"
/home/andyman/.opam/4.01.0+32bit/lib/bin_prot: added to search path /home/andyman/.opam/4.01.0+32bit/lib/bin_prot/bin_prot.cma: loaded
#require "variantslib,sexplib"
/home/andyman/.opam/4.01.0+32bit/lib/variantslib: added to search path /home/andyman/.opam/4.01.0+32bit/lib/variantslib/variantslib.cma: loaded /home/andyman/.opam/4.01.0+32bit/lib/sexplib: added to search path /home/andyman/.opam/4.01.0+32bit/lib/sexplib/sexplib.cma: loaded
#require "fieldslib,pa_bench,oUnit,pa_ounit"
/home/andyman/.opam/4.01.0+32bit/lib/fieldslib: added to search path /home/andyman/.opam/4.01.0+32bit/lib/fieldslib/fieldslib.cma: loaded /home/andyman/.opam/4.01.0+32bit/lib/pa_bench: added to search path /home/andyman/.opam/4.01.0+32bit/lib/pa_bench/pa_bench_lib.cma: loaded /home/andyman/.opam/4.01.0+32bit/lib/oUnit: added to search path /home/andyman/.opam/4.01.0+32bit/lib/oUnit/oUnitAdvanced.cma: loaded /home/andyman/.opam/4.01.0+32bit/lib/oUnit/oUnit.cma: loaded /home/andyman/.opam/4.01.0+32bit/lib/pa_ounit: added to search path /home/andyman/.opam/4.01.0+32bit/lib/pa_ounit/pa_ounit_lib.cma: loaded
#require "typerep_lib"
/home/andyman/.opam/4.01.0+32bit/lib/typerep_lib: added to search path /home/andyman/.opam/4.01.0+32bit/lib/typerep_lib/typerep_lib.cma: loaded
Exception: Failure "TypeError: Cannot read property '1' of undefined".
#require "core_kernel"
/home/andyman/.opam/4.01.0+32bit/lib/enumerate: added to search path /home/andyman/.opam/4.01.0+32bit/lib/core_kernel: added to search path /home/andyman/.opam/4.01.0+32bit/lib/core_kernel/raise_without_backtrace.cma: loaded /home/andyman/.opam/4.01.0+32bit/lib/core_kernel/core_kernel.cma: loaded
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.
#directory "/home/andyman/dev/github/forks/typerep/_build/lib"
#load "named_intf.cmo"
#load "type_equal.cmo"
Type_equal.conv
#load "typename.cmo"
#load "variant_and_record_intf.cmo"
#load "std_internal.cmo"
Exception: Failure "TypeError: Cannot read property '1' of undefined".
So our problems start in std_internal.cmo
.
#load "make_typename.cmo"
#load "typerepable.cmo"
#load "type_abstract.cmo"
#load "type_generic_intf.cmo"
#load "type_generic.cmo"
#load "typerep_obj.cmo"
#load "std.cmo"
My suspicion is it is the recursive module defined in std_internal
. Lets have a play.
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
The error comes with the addition of the arity
function.
Lets try to simplify a bit.
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
Remove the rec
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