make many modules extensions of stdlib (close #109)

for : Random Array List ArrayLabels ListLabels Char String
This commit is contained in:
Simon Cruanes 2017-05-01 16:38:44 +02:00
parent 0c4bf82c5c
commit 75e3962ba1
16 changed files with 34 additions and 40 deletions

View file

@ -432,9 +432,7 @@ module Tbl = struct
let arg_make : type a. a key_type -> (module KEY with type t = a) * string
= function
| Int -> (module CCInt), "int"
| Str ->
let module S = struct type t = string include CCString end in
(module S : KEY with type t = string), "string"
| Str -> (module CCString : KEY with type t = string), "string"
let sprintf = Printf.sprintf

View file

@ -18,6 +18,8 @@ type 'a printer = Format.formatter -> 'a -> unit
(** {2 Arrays} *)
include Array
type 'a t = 'a array
let empty = [| |]

View file

@ -13,6 +13,8 @@ type 'a printer = Format.formatter -> 'a -> unit
(** {2 Arrays} *)
include module type of Array
type 'a t = 'a array
val empty : 'a t

View file

@ -18,6 +18,8 @@ type 'a printer = Format.formatter -> 'a -> unit
(** {2 Arrays} *)
include ArrayLabels
type 'a t = 'a array
let empty = [| |]

View file

@ -13,6 +13,8 @@ type 'a printer = Format.formatter -> 'a -> unit
(** {2 Arrays} *)
include module type of ArrayLabels
type 'a t = 'a array
val empty : 'a t

View file

@ -4,10 +4,9 @@
@since 0.14 *)
type t = char
include Char
let equal (a:char) b = a=b
let compare = Char.compare
let pp = Buffer.add_char
let print = Format.pp_print_char

View file

@ -4,7 +4,7 @@
@since 0.14 *)
type t = char
include module type of Char
val equal : t -> t -> bool
val compare : t -> t -> int

View file

@ -9,6 +9,8 @@
type 'a t = 'a list
include List
let empty = []
let is_empty = function

View file

@ -9,6 +9,8 @@ type 'a klist = unit -> [`Nil | `Cons of 'a * 'a klist]
type 'a printer = Format.formatter -> 'a -> unit
type 'a random_gen = Random.State.t -> 'a
include module type of List
type 'a t = 'a list
val empty : 'a t

View file

@ -7,6 +7,8 @@
let lsort l = List.sort Pervasives.compare l
*)
include ListLabels
type 'a t = 'a list
let empty = []

View file

@ -3,6 +3,8 @@
(** {1 complements to list} *)
include module type of ListLabels
type 'a t = 'a list
val empty : 'a t

View file

@ -3,6 +3,8 @@
(** {1 Random Generators} *)
include Random
type state = Random.State.t
type 'a t = state -> 'a

View file

@ -3,6 +3,8 @@
(** {1 Random Generators} *)
include module type of Random
type state = Random.State.t
type 'a t = state -> 'a

View file

@ -7,6 +7,8 @@ type 'a gen = unit -> 'a option
type 'a sequence = ('a -> unit) -> unit
type 'a klist = unit -> [`Nil | `Cons of 'a * 'a klist]
include String
module type S = sig
type t

View file

@ -48,6 +48,8 @@ end
(** {2 Strings} *)
include module type of String
val equal : string -> string -> bool
val compare : string -> string -> int

View file

@ -1,25 +1,10 @@
(* 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,
[List] and [CCList]. Instead, [List] is now an alias to
{[struct
include List
include CCList
end
]}
*)
module Array = struct
include Array
include CCArray
end
module ArrayLabels = struct
include ArrayLabels
include CCArrayLabels
end
module Array = CCArray
module ArrayLabels = CCArrayLabels
module Array_slice = CCArray_slice
module Bool = CCBool
module Char = struct
@ -50,14 +35,8 @@ module Hashtbl = struct
module Make' = CCHashtbl.Make
end
module Heap = CCHeap
module List = struct
include List
include CCList
end
module ListLabels = struct
include ListLabels
include CCListLabels
end
module List = CCList
module ListLabels = CCListLabels
module Map = struct
module type OrderedType = Map.OrderedType
include CCMap
@ -66,10 +45,7 @@ module Option = CCOpt
module Ord = CCOrd
module Pair = CCPair
module Parse = CCParse
module Random = struct
include Random
include CCRandom
end
module Random = CCRandom
module Ref = CCRef
module Result = struct
include Result
@ -79,8 +55,5 @@ module Set = struct
module type OrderedType = Set.OrderedType
include CCSet
end
module String = struct
include String
include CCString
end
module String = CCString
module Vector = CCVector