wip: add to_std_seq

see #254
This commit is contained in:
Simon Cruanes 2019-11-20 17:50:40 -06:00
parent 78ef007b77
commit 7d1862a501
4 changed files with 56 additions and 31 deletions

View file

@ -13,6 +13,7 @@ depends: [
"dune" "dune"
"result" "result"
"uchar" "uchar"
"seq"
"qtest" { with-test } "qtest" { with-test }
"qcheck" { with-test } "qcheck" { with-test }
"ounit" { with-test } "ounit" { with-test }

View file

@ -1,4 +1,3 @@
(* 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 Options} *) (** {1 Options} *)
@ -210,6 +209,10 @@ let to_iter o k = match o with
let to_seq = to_iter let to_seq = to_iter
let to_std_seq o () = match o with
| None -> Seq.Nil
| Some x -> Seq.Cons (x, Seq.empty)
let pp ppx out = function let pp ppx out = function
| None -> Format.pp_print_string out "None" | None -> Format.pp_print_string out "None"
| Some x -> Format.fprintf out "@[Some %a@]" ppx x | Some x -> Format.fprintf out "@[Some %a@]" ppx x

View file

@ -1,4 +1,3 @@
(* 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 Options} *) (** {1 Options} *)
@ -187,6 +186,10 @@ val choice_seq : 'a t sequence -> 'a t
val to_gen : 'a t -> 'a gen val to_gen : 'a t -> 'a gen
val to_std_seq : 'a t -> 'a Seq.t
(** Same as {!Stdlib.Option.to_seq}
@since NEXT_RELEASE *)
val to_iter : 'a t -> 'a sequence val to_iter : 'a t -> 'a sequence
(** Returns an internal iterator, like in the library [Iter]. (** Returns an internal iterator, like in the library [Iter].
@since NEXT_RELEASE *) @since NEXT_RELEASE *)

View file

@ -1,44 +1,62 @@
(alias (alias
(name unlabel) (name unlabel)
(deps (:mli CCArrayLabels.mli) ../unlabel.exe) (deps
(action (run ../unlabel.exe %{mli} CCArray.mli))) (:mli CCArrayLabels.mli)
../unlabel.exe)
(action
(run ../unlabel.exe %{mli} CCArray.mli)))
(alias (alias
(name unlabel) (name unlabel)
(deps (:mli CCArray_sliceLabels.mli) ../unlabel.exe) (deps
(action (run ../unlabel.exe %{mli} CCArray_slice.mli))) (:mli CCArray_sliceLabels.mli)
../unlabel.exe)
(action
(run ../unlabel.exe %{mli} CCArray_slice.mli)))
(alias (alias
(name unlabel) (name unlabel)
(deps (:mli CCEqualLabels.mli) ../unlabel.exe) (deps
(action (run ../unlabel.exe %{mli} CCEqual.mli))) (:mli CCEqualLabels.mli)
../unlabel.exe)
(action
(run ../unlabel.exe %{mli} CCEqual.mli)))
(alias (alias
(name unlabel) (name unlabel)
(deps (:mli CCListLabels.mli) ../unlabel.exe) (deps
(action (run ../unlabel.exe %{mli} CCList.mli))) (:mli CCListLabels.mli)
../unlabel.exe)
(action
(run ../unlabel.exe %{mli} CCList.mli)))
(alias (alias
(name unlabel) (name unlabel)
(deps (:mli CCStringLabels.mli) ../unlabel.exe) (deps
(action (run ../unlabel.exe %{mli} CCString.mli))) (:mli CCStringLabels.mli)
../unlabel.exe)
(action
(run ../unlabel.exe %{mli} CCString.mli)))
(executable (executable
(name mkshims) (name mkshims)
(modules mkshims) (modules mkshims)
(libraries dune.configurator)) (libraries dune.configurator))
(rule (rule
(targets CCShims_.ml CCShimsList_.ml CCShimsFun_.ml CCShimsFun_.mli CCShimsArray_.ml CCShimsFormat_.ml) (targets CCShims_.ml CCShimsList_.ml CCShimsFun_.ml CCShimsFun_.mli
(deps ./mkshims.exe) CCShimsArray_.ml CCShimsFormat_.ml)
(action (run ./mkshims.exe))) (deps ./mkshims.exe)
(action
(run ./mkshims.exe)))
(library (library
(name containers) (name containers)
(public_name containers) (public_name containers)
(wrapped false) (wrapped false)
(modules :standard \ mkshims) (modules :standard \ mkshims)
(flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -nolabels -open CCMonomorphic) (flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -nolabels -open
(ocamlopt_flags (:include ../flambda.flags)) CCMonomorphic)
(libraries result uchar containers.monomorphic)) (ocamlopt_flags
(:include ../flambda.flags))
(libraries result uchar seq containers.monomorphic))