Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions jscomp/bsb/bsb_templates.ml
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,19 @@ let root = OCamlRes.Res.([
"{\n\
\ \"name\": \"${bsb:name}\",\n\
\ \"version\": \"${bsb:proj-version}\",\n\
\ \"sources\": [{\n\
\ \"sources\": {\n\
\ \"dir\": \"src\",\n\
\ \"generators\": [{\n\
\ \"name\": \"cpp\",\n\
\ \"edge\": [\"test.ml\", \":\", \"test.cpp.ml\"]\n\
\ }]\n\
\ }],\n\
\ }],\n\
\ \"subdirs\": true \n\
\ },\n\
\ \"generators\": [{\n\
\ \"name\" : \"cpp\",\n\
\ \"command\": \"sed 's/OCAML/3/' $in > $out\"\n\
\ }],\n\
\ \"bs-dependencies\" : [\n\
\ // add your bs-dependencies here \n\
\ ]\n\
}") ;
File (".gitignore",
Expand Down Expand Up @@ -366,7 +366,10 @@ let root = OCamlRes.Res.([
File ("bsconfig.json",
"{\n\
\ \"name\": \"${bsb:name}\",\n\
\ \"sources\": [\"src\"]\n\
\ \"sources\": {\n\
\ \"dir\": \"src\",\n\
\ \"subdirs\": true\n\
\ }\n\
}") ;
File (".gitignore",
".DS_Store\n\
Expand Down Expand Up @@ -421,17 +424,17 @@ let root = OCamlRes.Res.([
"{\n\
\ \"name\": \"${bsb:name}\",\n\
\ \"version\": \"${bsb:proj-version}\",\n\
\ \"sources\": [\n\
\ \"src\"\n\
\ ],\n\
\ \"sources\": {\n\
\ \"dir\": \"src\",\n\
\ \"subdirs\" : true\n\
\ },\n\
\ \"package-specs\": {\n\
\ \"module\": \"commonjs\",\n\
\ \"in-source\": true\n\
\ },\n\
\ \"suffix\": \".bs.js\",\n\
\ \"bs-dependencies\": [\n\
\ // add your bs-dependencies here \n\
\ ]\n\
\ ]\n\
}") ;
File (".gitignore",
"*.exe\n\
Expand Down Expand Up @@ -566,9 +569,10 @@ let root = OCamlRes.Res.([
\ \"reason\": {\n\
\ \"react-jsx\": 2\n\
\ },\n\
\ \"sources\": [\n\
\ \"src\"\n\
\ ],\n\
\ \"sources\": {\n\
\ \"dir\" : \"src\",\n\
\ \"subdirs\" : true\n\
\ },\n\
\ \"package-specs\": [{\n\
\ \"module\": \"commonjs\",\n\
\ \"in-source\": true\n\
Expand Down
56 changes: 26 additions & 30 deletions jscomp/others/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ js_console.cmj :
js_result.cmj : js_result.cmi
js_mapperRt.cmj : js_mapperRt.cmi
bs_Array.cmj : js_math.cmj bs_Array.cmi
bs_internalAVLset.cmj : bs_SortArray.cmj bs_Cmp.cmj bs_Array.cmj \
bs_internalAVLset.cmj : bs_SortArray.cmj bs_Dict.cmj bs_Array.cmj \
bs_internalAVLset.cmi
bs_internalAVLtree.cmj : bs_SortArray.cmj bs_Cmp.cmj bs_Array.cmj \
bs_internalAVLtree.cmj : bs_SortArray.cmj bs_Dict.cmj bs_Array.cmj \
bs_internalAVLtree.cmi
bs_SetIntM.cmj : bs_internalSetInt.cmj bs_internalAVLset.cmj \
bs_SortArrayInt.cmj bs_Array.cmj bs_SetIntM.cmi
bs_Hash.cmj : bs_Hash.cmi
bs_Queue.cmj : bs_Array.cmj bs_Queue.cmi
bs_List.cmj : bs_Array.cmj bs_List.cmi
bs_SortArray.cmj : bs_SortArrayString.cmj bs_SortArrayInt.cmj bs_Array.cmj \
Expand All @@ -37,25 +36,23 @@ bs_internalSetBuckets.cmj : bs_internalBucketsType.cmj bs_Array.cmj bs.cmj \
bs_internalBuckets.cmj : bs_internalBucketsType.cmj bs_Array.cmj \
bs_internalBuckets.cmi
bs_HashMap.cmj : bs_internalBucketsType.cmj bs_internalBuckets.cmj \
bs_HashMapString.cmj bs_HashMapInt.cmj bs_Hash.cmj bs_Array.cmj \
bs_HashMapString.cmj bs_HashMapInt.cmj bs_Dict.cmj bs_Array.cmj \
bs_HashMap.cmi
bs_HashMultiMap.cmj : bs_internalBucketsType.cmj bs_internalBuckets.cmj \
bs_Hash.cmj bs_Array.cmj bs_HashMultiMap.cmi
bs_Dict.cmj bs_Array.cmj bs_HashMultiMap.cmi
bs_HashSet.cmj : bs_internalSetBuckets.cmj bs_internalBucketsType.cmj \
bs_HashSetString.cmj bs_HashSetInt.cmj bs_Hash.cmj bs_Array.cmj \
bs_HashSetString.cmj bs_HashSetInt.cmj bs_Dict.cmj bs_Array.cmj \
bs_HashSet.cmi
bs_HashSetString.cmj : bs_internalSetBuckets.cmj bs_internalBucketsType.cmj \
bs_Array.cmj bs_HashSetString.cmi
bs_HashSetInt.cmj : bs_internalSetBuckets.cmj bs_internalBucketsType.cmj \
bs_Array.cmj bs_HashSetInt.cmi
bs_Bag.cmj :
bs_BagM.cmj :
bs_Cmp.cmj : bs_Cmp.cmi
bs_SortedMapDict.cmj : bs_internalAVLtree.cmj bs_Cmp.cmj bs_Array.cmj \
bs_SortedMapDict.cmi
bs_SortedSetDict.cmj : bs_internalAVLset.cmj bs_Cmp.cmj bs_Array.cmj \
bs_SortedSetDict.cmi
bs_Map.cmj : bs_SortedMapDict.cmj bs_MapString.cmj bs_MapInt.cmj bs_Cmp.cmj \
bs_Dict.cmj : bs_Dict.cmi
bs_MapDict.cmj : bs_internalAVLtree.cmj bs_Dict.cmj bs_Array.cmj \
bs_MapDict.cmi
bs_SetDict.cmj : bs_internalAVLset.cmj bs_Dict.cmj bs_Array.cmj \
bs_SetDict.cmi
bs_Map.cmj : bs_MapString.cmj bs_MapInt.cmj bs_MapDict.cmj bs_Dict.cmj \
bs_Array.cmj bs_Map.cmi
bs_internalMapInt.cmj : bs_internalAVLtree.cmj bs_SortArray.cmj bs_Array.cmj
bs_internalMapString.cmj : bs_internalAVLtree.cmj bs_SortArray.cmj \
Expand All @@ -68,12 +65,12 @@ bs_MapStringM.cmj : bs_internalMapString.cmj bs_internalAVLtree.cmj \
bs_Array.cmj bs_MapStringM.cmi
bs_MapIntM.cmj : bs_internalMapInt.cmj bs_internalAVLtree.cmj bs_Array.cmj \
bs_MapIntM.cmi
bs_Set.cmj : bs_SortedSetDict.cmj bs_SetString.cmj bs_SetInt.cmj bs_Cmp.cmj \
bs_Set.cmj : bs_SetString.cmj bs_SetInt.cmj bs_SetDict.cmj bs_Dict.cmj \
bs_Array.cmj bs_Set.cmi
bs_SetM.cmj : bs_internalAVLset.cmj bs_SortArray.cmj bs_SetStringM.cmj \
bs_SetIntM.cmj bs_Cmp.cmj bs_Array.cmj bs_SetM.cmi
bs_SetIntM.cmj bs_Dict.cmj bs_Array.cmj bs_SetM.cmi
bs_MapM.cmj : bs_internalAVLtree.cmj bs_MapStringM.cmj bs_MapIntM.cmj \
bs_Cmp.cmj bs_Array.cmj bs_MapM.cmi
bs_Dict.cmj bs_Array.cmj bs_MapM.cmi
bs_internalSetInt.cmj : bs_internalAVLset.cmj bs_SortArrayInt.cmj \
bs_Array.cmj
bs_internalSetString.cmj : bs_internalAVLset.cmj bs_SortArrayString.cmj \
Expand Down Expand Up @@ -110,10 +107,9 @@ js_option.cmi :
js_result.cmi :
js_mapperRt.cmi :
bs_Array.cmi :
bs_internalAVLset.cmi : bs_Cmp.cmi
bs_internalAVLtree.cmi : bs_Cmp.cmi
bs_internalAVLset.cmi : bs_Dict.cmi
bs_internalAVLtree.cmi : bs_Dict.cmi
bs_SetIntM.cmi :
bs_Hash.cmi :
bs_Queue.cmi :
bs_List.cmi :
bs_SortArray.cmi : bs_SortArrayString.cmi bs_SortArrayInt.cmi
Expand All @@ -123,22 +119,22 @@ bs_Range.cmi :
bs_internalBucketsType.cmi :
bs_internalSetBuckets.cmi : bs_internalBucketsType.cmi
bs_internalBuckets.cmi : bs_internalBucketsType.cmi
bs_HashMap.cmi : bs_HashMapString.cmi bs_HashMapInt.cmi bs_Hash.cmi
bs_HashMultiMap.cmi : bs_Hash.cmi
bs_HashSet.cmi : bs_HashSetString.cmi bs_HashSetInt.cmi bs_Hash.cmi
bs_HashMap.cmi : bs_HashMapString.cmi bs_HashMapInt.cmi bs_Dict.cmi
bs_HashMultiMap.cmi : bs_Dict.cmi
bs_HashSet.cmi : bs_HashSetString.cmi bs_HashSetInt.cmi bs_Dict.cmi
bs_HashSetString.cmi :
bs_HashSetInt.cmi :
bs_Cmp.cmi :
bs_SortedMapDict.cmi : bs_Cmp.cmi
bs_SortedSetDict.cmi : bs_Cmp.cmi
bs_Map.cmi : bs_SortedMapDict.cmi bs_MapString.cmi bs_MapInt.cmi bs_Cmp.cmi
bs_Dict.cmi :
bs_MapDict.cmi : bs_Dict.cmi
bs_SetDict.cmi : bs_Dict.cmi
bs_Map.cmi : bs_MapString.cmi bs_MapInt.cmi bs_MapDict.cmi bs_Dict.cmi
bs_MapString.cmi :
bs_MapInt.cmi :
bs_MapStringM.cmi :
bs_MapIntM.cmi :
bs_Set.cmi : bs_SortedSetDict.cmi bs_SetString.cmi bs_SetInt.cmi bs_Cmp.cmi
bs_SetM.cmi : bs_SetStringM.cmi bs_SetIntM.cmi bs_Cmp.cmi
bs_MapM.cmi : bs_MapStringM.cmi bs_MapIntM.cmi bs_Cmp.cmi
bs_Set.cmi : bs_SetString.cmi bs_SetInt.cmi bs_SetDict.cmi bs_Dict.cmi
bs_SetM.cmi : bs_SetStringM.cmi bs_SetIntM.cmi bs_Dict.cmi
bs_MapM.cmi : bs_MapStringM.cmi bs_MapIntM.cmi bs_Dict.cmi
bs_SetInt.cmi :
bs_SetIntM.cmi :
bs_SetString.cmi :
Expand Down
11 changes: 5 additions & 6 deletions jscomp/others/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ SOURCE_LIST= node_path node_fs node_process dict node_module js_array js_string
bs_internalAVLtree\
bs_SetIntM\
bs_internalMutableAVL\
bs_Hash\
bs_Queue\
bs_List\
bs_SortArray\
Expand All @@ -30,11 +29,9 @@ SOURCE_LIST= node_path node_fs node_process dict node_module js_array js_string
bs_HashSet\
bs_HashSetString\
bs_HashSetInt\
bs_Bag\
bs_BagM\
bs_Cmp\
bs_SortedMapDict\
bs_SortedSetDict\
bs_Dict\
bs_MapDict\
bs_SetDict\
bs_Map\
bs_internalMapInt\
bs_internalMapString\
Expand All @@ -60,6 +57,8 @@ SOURCE_LIST= node_path node_fs node_process dict node_module js_array js_string
bs_HashMapInt\
bs_HashMapString\

# bs_Bag\
# bs_BagM\
# bs_dyn bs_dyn_lib\

$(addsuffix .cmj, $(SOURCE_LIST)): $(addsuffix .cmj, $(MAP_FILES))
Expand Down
18 changes: 10 additions & 8 deletions jscomp/others/bs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@

(**/*)
(**/*)
module Cmp = Bs_Cmp
module Hash = Bs_Hash

module Dict = Bs_Dict
module Array = Bs_Array
module Queue = Bs_Queue
module MutableQueue = Bs_Queue
module List = Bs_List
module Stack = Bs_Stack
module MutableStack = Bs_Stack
module Range = Bs_Range

(** Immutable sorted set *)
module Set = Bs_Set

(** The implementation detail for {!Bs.Set}, also slightly more efficient *)
module SetDict = Bs_SortedSetDict
(** The implementation detail for {!Bs.Set}, also slightly more efficient,
can also be accessed via {!Bs.Set.Dict} *)
module SetDict = Bs_SetDict

(** can also be accessed via {!Bs.Set.Int}*)
module SetInt = Bs_SetInt
Expand Down Expand Up @@ -67,8 +68,9 @@ module UnorderedMutableSetString = Bs_HashSetString

module Map = Bs_Map

(** The implementaion detail for {!Bs.Map}, also slightly more efficient*)
module MapDict = Bs_SortedMapDict
(** The implementaion detail for {!Bs.Map}, also slightly more efficient,
can also be accessed via {!Bs.Map.Dict}*)
module MapDict = Bs_MapDict

(** can also be accessed via {!Bs.Map.Int}*)
module MapInt = Bs_MapInt
Expand Down
67 changes: 51 additions & 16 deletions jscomp/others/bs_Cmp.ml → jscomp/others/bs_Dict.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,71 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

type 'a compare = ('a -> 'a -> int [@bs])
type ('a,'id) cmp = 'a compare

external getCmpInternal : ('a,'id) cmp -> 'a compare = "%identity"
type ('a, 'id) hash = ('a -> int [@bs])
type ('a, 'id) eq = ('a -> 'a -> bool [@bs])
type ('a, 'id) cmp = ('a -> 'a -> int [@bs])

external getHashInternal : ('a,'id) hash -> ('a -> int [@bs]) = "%identity"
external getEqInternal : ('a, 'id) eq -> ('a -> 'a -> bool [@bs]) = "%identity"
external getCmpInternal : ('a,'id) cmp -> ('a -> 'a -> int [@bs]) = "%identity"

module type T = sig

module type Comparable = sig
type id
type t
val cmp : (t,id) cmp
val cmp: (t, id) cmp
end
type ('key, 'id) t = (module T with type t = 'key and type id = 'id)

module Make (M : sig
type ('key, 'id) comparable = (module Comparable with type t = 'key and type id = 'id)


module MakeComparable (M : sig
type t
val cmp : t -> t -> int [@bs]
val cmp: t -> t -> int [@bs]
end) =
struct
type id
type t = M.t
let cmp = M.cmp
end

let make
let comparable
(type key)
~(cmp : key -> key -> int [@bs])
~cmp
=
let module M = struct
type t = key
let cmp = cmp
end in
let module N = Make(M) in
(module N : T with type t = key)
let module N = MakeComparable(struct
type t = key
let cmp = cmp
end) in
(module N : Comparable with type t = key)


module type Hashable = sig
type id
type t
val hash: (t,id) hash
val eq: (t,id) eq
end

type ('key, 'id) hashable = (module Hashable with type t = 'key and type id = 'id)

module MakeHashable (M : sig
type t
val hash : t -> int [@bs]
val eq : t -> t -> bool [@bs]
end) =
struct
type id
type t = M.t
let hash = M.hash
let eq = M.eq
end

let hashable (type key) ~hash ~eq =
let module N = MakeHashable(struct
type t = key
let hash = hash
let eq = eq
end) in
(module N : Hashable with type t = key)
Loading