mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
make many modules extensions of stdlib (close #109)
for : Random Array List ArrayLabels ListLabels Char String
This commit is contained in:
parent
0c4bf82c5c
commit
75e3962ba1
16 changed files with 34 additions and 40 deletions
|
|
@ -432,9 +432,7 @@ module Tbl = struct
|
||||||
let arg_make : type a. a key_type -> (module KEY with type t = a) * string
|
let arg_make : type a. a key_type -> (module KEY with type t = a) * string
|
||||||
= function
|
= function
|
||||||
| Int -> (module CCInt), "int"
|
| Int -> (module CCInt), "int"
|
||||||
| Str ->
|
| Str -> (module CCString : KEY with type t = string), "string"
|
||||||
let module S = struct type t = string include CCString end in
|
|
||||||
(module S : KEY with type t = string), "string"
|
|
||||||
|
|
||||||
let sprintf = Printf.sprintf
|
let sprintf = Printf.sprintf
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ type 'a printer = Format.formatter -> 'a -> unit
|
||||||
|
|
||||||
(** {2 Arrays} *)
|
(** {2 Arrays} *)
|
||||||
|
|
||||||
|
include Array
|
||||||
|
|
||||||
type 'a t = 'a array
|
type 'a t = 'a array
|
||||||
|
|
||||||
let empty = [| |]
|
let empty = [| |]
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ type 'a printer = Format.formatter -> 'a -> unit
|
||||||
|
|
||||||
(** {2 Arrays} *)
|
(** {2 Arrays} *)
|
||||||
|
|
||||||
|
include module type of Array
|
||||||
|
|
||||||
type 'a t = 'a array
|
type 'a t = 'a array
|
||||||
|
|
||||||
val empty : 'a t
|
val empty : 'a t
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ type 'a printer = Format.formatter -> 'a -> unit
|
||||||
|
|
||||||
(** {2 Arrays} *)
|
(** {2 Arrays} *)
|
||||||
|
|
||||||
|
include ArrayLabels
|
||||||
|
|
||||||
type 'a t = 'a array
|
type 'a t = 'a array
|
||||||
|
|
||||||
let empty = [| |]
|
let empty = [| |]
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ type 'a printer = Format.formatter -> 'a -> unit
|
||||||
|
|
||||||
(** {2 Arrays} *)
|
(** {2 Arrays} *)
|
||||||
|
|
||||||
|
include module type of ArrayLabels
|
||||||
|
|
||||||
type 'a t = 'a array
|
type 'a t = 'a array
|
||||||
|
|
||||||
val empty : 'a t
|
val empty : 'a t
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,9 @@
|
||||||
|
|
||||||
@since 0.14 *)
|
@since 0.14 *)
|
||||||
|
|
||||||
type t = char
|
include Char
|
||||||
|
|
||||||
let equal (a:char) b = a=b
|
let equal (a:char) b = a=b
|
||||||
let compare = Char.compare
|
|
||||||
|
|
||||||
let pp = Buffer.add_char
|
let pp = Buffer.add_char
|
||||||
let print = Format.pp_print_char
|
let print = Format.pp_print_char
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
@since 0.14 *)
|
@since 0.14 *)
|
||||||
|
|
||||||
type t = char
|
include module type of Char
|
||||||
|
|
||||||
val equal : t -> t -> bool
|
val equal : t -> t -> bool
|
||||||
val compare : t -> t -> int
|
val compare : t -> t -> int
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
type 'a t = 'a list
|
type 'a t = 'a list
|
||||||
|
|
||||||
|
include List
|
||||||
|
|
||||||
let empty = []
|
let empty = []
|
||||||
|
|
||||||
let is_empty = function
|
let is_empty = function
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ type 'a klist = unit -> [`Nil | `Cons of 'a * 'a klist]
|
||||||
type 'a printer = Format.formatter -> 'a -> unit
|
type 'a printer = Format.formatter -> 'a -> unit
|
||||||
type 'a random_gen = Random.State.t -> 'a
|
type 'a random_gen = Random.State.t -> 'a
|
||||||
|
|
||||||
|
include module type of List
|
||||||
|
|
||||||
type 'a t = 'a list
|
type 'a t = 'a list
|
||||||
|
|
||||||
val empty : 'a t
|
val empty : 'a t
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
let lsort l = List.sort Pervasives.compare l
|
let lsort l = List.sort Pervasives.compare l
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
include ListLabels
|
||||||
|
|
||||||
type 'a t = 'a list
|
type 'a t = 'a list
|
||||||
|
|
||||||
let empty = []
|
let empty = []
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
(** {1 complements to list} *)
|
(** {1 complements to list} *)
|
||||||
|
|
||||||
|
include module type of ListLabels
|
||||||
|
|
||||||
type 'a t = 'a list
|
type 'a t = 'a list
|
||||||
|
|
||||||
val empty : 'a t
|
val empty : 'a t
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
(** {1 Random Generators} *)
|
(** {1 Random Generators} *)
|
||||||
|
|
||||||
|
include Random
|
||||||
|
|
||||||
type state = Random.State.t
|
type state = Random.State.t
|
||||||
|
|
||||||
type 'a t = state -> 'a
|
type 'a t = state -> 'a
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
(** {1 Random Generators} *)
|
(** {1 Random Generators} *)
|
||||||
|
|
||||||
|
include module type of Random
|
||||||
|
|
||||||
type state = Random.State.t
|
type state = Random.State.t
|
||||||
|
|
||||||
type 'a t = state -> 'a
|
type 'a t = state -> 'a
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ type 'a gen = unit -> 'a option
|
||||||
type 'a sequence = ('a -> unit) -> unit
|
type 'a sequence = ('a -> unit) -> unit
|
||||||
type 'a klist = unit -> [`Nil | `Cons of 'a * 'a klist]
|
type 'a klist = unit -> [`Nil | `Cons of 'a * 'a klist]
|
||||||
|
|
||||||
|
include String
|
||||||
|
|
||||||
module type S = sig
|
module type S = sig
|
||||||
type t
|
type t
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,8 @@ end
|
||||||
|
|
||||||
(** {2 Strings} *)
|
(** {2 Strings} *)
|
||||||
|
|
||||||
|
include module type of String
|
||||||
|
|
||||||
val equal : string -> string -> bool
|
val equal : string -> string -> bool
|
||||||
|
|
||||||
val compare : string -> string -> int
|
val compare : string -> string -> int
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,10 @@
|
||||||
|
|
||||||
(* This file is free software, part of containers. See file "license" for more details. *)
|
(* This file is free software, part of containers. See file "license" for more details. *)
|
||||||
|
|
||||||
(** {1 Drop-In replacement to Stdlib}
|
(** {1 Drop-In replacement to Stdlib} *)
|
||||||
|
|
||||||
This module is meant to be opened if one doesn't want to use both, say,
|
module Array = CCArray
|
||||||
[List] and [CCList]. Instead, [List] is now an alias to
|
module ArrayLabels = CCArrayLabels
|
||||||
{[struct
|
|
||||||
include List
|
|
||||||
include CCList
|
|
||||||
end
|
|
||||||
]}
|
|
||||||
*)
|
|
||||||
|
|
||||||
module Array = struct
|
|
||||||
include Array
|
|
||||||
include CCArray
|
|
||||||
end
|
|
||||||
module ArrayLabels = struct
|
|
||||||
include ArrayLabels
|
|
||||||
include CCArrayLabels
|
|
||||||
end
|
|
||||||
module Array_slice = CCArray_slice
|
module Array_slice = CCArray_slice
|
||||||
module Bool = CCBool
|
module Bool = CCBool
|
||||||
module Char = struct
|
module Char = struct
|
||||||
|
|
@ -50,14 +35,8 @@ module Hashtbl = struct
|
||||||
module Make' = CCHashtbl.Make
|
module Make' = CCHashtbl.Make
|
||||||
end
|
end
|
||||||
module Heap = CCHeap
|
module Heap = CCHeap
|
||||||
module List = struct
|
module List = CCList
|
||||||
include List
|
module ListLabels = CCListLabels
|
||||||
include CCList
|
|
||||||
end
|
|
||||||
module ListLabels = struct
|
|
||||||
include ListLabels
|
|
||||||
include CCListLabels
|
|
||||||
end
|
|
||||||
module Map = struct
|
module Map = struct
|
||||||
module type OrderedType = Map.OrderedType
|
module type OrderedType = Map.OrderedType
|
||||||
include CCMap
|
include CCMap
|
||||||
|
|
@ -66,10 +45,7 @@ module Option = CCOpt
|
||||||
module Ord = CCOrd
|
module Ord = CCOrd
|
||||||
module Pair = CCPair
|
module Pair = CCPair
|
||||||
module Parse = CCParse
|
module Parse = CCParse
|
||||||
module Random = struct
|
module Random = CCRandom
|
||||||
include Random
|
|
||||||
include CCRandom
|
|
||||||
end
|
|
||||||
module Ref = CCRef
|
module Ref = CCRef
|
||||||
module Result = struct
|
module Result = struct
|
||||||
include Result
|
include Result
|
||||||
|
|
@ -79,8 +55,5 @@ module Set = struct
|
||||||
module type OrderedType = Set.OrderedType
|
module type OrderedType = Set.OrderedType
|
||||||
include CCSet
|
include CCSet
|
||||||
end
|
end
|
||||||
module String = struct
|
module String = CCString
|
||||||
include String
|
|
||||||
include CCString
|
|
||||||
end
|
|
||||||
module Vector = CCVector
|
module Vector = CCVector
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue