-
Notifications
You must be signed in to change notification settings - Fork 17
Remove use of Vector #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c1eb949
Remove use of Vector
giltho be02979
Compatible with 4.08, install Vector if < 5.2.0
giltho b62f882
remove dune-generated warning
giltho ff97864
oops, fmt
giltho 24f6a80
Apply @kit-ty-kate's comments
giltho bfdc63d
oops
giltho 3d8d178
use library instead of rules, to be able to specify dependency on vec…
giltho 5d1f12e
remove package information from dune-project
giltho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,44 +2,7 @@ | |
| (name progress) | ||
| (implicit_transitive_deps false) | ||
|
|
||
| (generate_opam_files true) | ||
| (source (github CraigFe/progress)) | ||
| (license MIT) | ||
| (maintainers "Craig Ferguson <[email protected]>") | ||
| (authors "Craig Ferguson <[email protected]>") | ||
|
|
||
| (package | ||
| (name progress) | ||
| (synopsis "User-definable progress bars") | ||
| (description "\ | ||
| A progress bar library for OCaml, featuring a DSL for declaratively specifying | ||
| progress bar formats. Supports rendering multiple progress bars simultaneously.\ | ||
| ") | ||
| (documentation https://CraigFe.github.io/progress/) | ||
| (depends | ||
| (ocaml (>= 4.08.0)) | ||
| (terminal (= :version)) | ||
| (fmt (>= 0.8.5)) | ||
| (logs (>= 0.7.0)) | ||
| (mtime (>= 2.0.0)) | ||
| (uucp (>= 2.0.0)) | ||
| (uutf (>= 1.0.0)) | ||
| vector | ||
| (optint (>= 0.1.0)) | ||
| (alcotest (and :with-test (>= 1.4.0))) | ||
| (astring :with-test))) | ||
|
|
||
| (package | ||
| (name terminal) | ||
| (synopsis "Basic utilities for interacting with terminals") | ||
| (description "Basic utilities for interacting with terminals") | ||
| (documentation https://CraigFe.github.io/progress/) | ||
| (depends | ||
| (ocaml (>= 4.03.0)) | ||
| (uucp (>= 2.0.0)) | ||
| (uutf (>= 1.0.0)) | ||
| stdlib-shims | ||
| (alcotest (and :with-test (>= 1.4.0))) | ||
| (fmt :with-test) | ||
| (astring :with-test) | ||
| (mtime (and :with-test (>= 2.0.0))))) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,9 @@ | ||
| val shuffle_vector : _ Vector.t -> unit | ||
| module Dynlist : sig | ||
| type 'a t | ||
|
|
||
| val of_list : 'a list -> 'a t | ||
| val length : 'a t -> int | ||
| val pop_opt : 'a t -> 'a option | ||
| end | ||
|
|
||
| val colour_picker : unit -> unit -> Progress.Color.t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,48 @@ | ||
| ; We use two different implementations of vectors depending on the availability of Dynarray in the standard library (starting OCaml 5.2). | ||
| ; This reduces dependencies fo users of the newer OCaml versions, and reduces clashes with the ecosystem (https://github.com/craigfe/progress/pull/50). | ||
|
|
||
| ; Rules for OCaml 5.2 and later | ||
|
|
||
| (rule | ||
| (enabled_if | ||
| (>= %{ocaml_version} "5.2")) | ||
| (action | ||
| (copy# pvector.dynarray.ml pvector.ml))) | ||
|
|
||
| (library | ||
| (name pvector) | ||
| (public_name progress.vector) | ||
| (enabled_if | ||
| (>= %{ocaml_version} "5.2")) | ||
| (modules pvector)) | ||
|
|
||
| ; Rules for OCaml versions after 5.2 | ||
|
|
||
| (rule | ||
| (enabled_if | ||
| (< %{ocaml_version} "5.2")) | ||
| (action | ||
| (copy# pvector.vector.ml pvector.ml))) | ||
|
|
||
| (library | ||
| (name pvector) | ||
| (public_name progress.vector) | ||
| (enabled_if | ||
| (< %{ocaml_version} "5.2")) | ||
giltho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (modules pvector) | ||
| (libraries vector)) | ||
|
|
||
| ; Main library | ||
|
|
||
| (library | ||
| (name progress_engine) | ||
| (public_name progress.engine) | ||
| (modules :standard \ pvector) | ||
| (libraries | ||
| (re_export mtime) | ||
| (re_export optint) | ||
| fmt | ||
| logs | ||
| logs.fmt | ||
| terminal_ansi | ||
| vector)) | ||
| progress.vector)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,42 +12,6 @@ module Mtime = struct | |
| let span_to_s span = Mtime.Span.to_float_ns span *. 1e-9 | ||
| end | ||
|
|
||
| module Vector = struct | ||
| include Vector | ||
|
|
||
| let iter ~f t = iter f t | ||
|
|
||
| let iteri_from ~f i t = | ||
| for i = i to length t - 1 do | ||
| f i (unsafe_get t i) | ||
| done | ||
|
|
||
| let rec find_map_from i t ~f = | ||
| if i >= length t then None | ||
| else | ||
| let a = unsafe_get t i in | ||
| match f a with | ||
| | Some _ as some -> some | ||
| | None -> find_map_from (i + 1) t ~f | ||
|
|
||
| let find_map t ~f = find_map_from 0 t ~f | ||
|
|
||
| let insert t k v = | ||
| Vector.push t v (* Dummy insertion to expand *); | ||
| for i = Vector.length t - 1 downto k + 1 do | ||
| Vector.set t i (Vector.get t (pred i)) | ||
| done; | ||
| Vector.set t k v | ||
|
|
||
| let remove (type a) (t : a t) k = | ||
| for i = k to Vector.length t - 2 do | ||
| Vector.set t i (Vector.get t (succ i)) | ||
| done; | ||
| ignore (Vector.pop t : a) | ||
|
|
||
| let get_exn = get | ||
| let get = `shadowed | ||
| end | ||
| (*———————————————————————————————————————————————————————————————————————————— | ||
| Copyright (c) 2020–2021 Craig Ferguson <[email protected]> | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| include Dynarray | ||
|
|
||
| let iter ~f t = iter f t | ||
|
|
||
| let iteri_from ~f i t = | ||
| for i = i to length t - 1 do | ||
| f i (get t i) | ||
| done | ||
|
|
||
| let of_list ~dummy:_ l = Dynarray.of_list l | ||
|
|
||
| let rec find_map_from i t ~f = | ||
| if i >= length t then None | ||
| else | ||
| let a = get t i in | ||
| match f a with Some _ as some -> some | None -> find_map_from (i + 1) t ~f | ||
|
|
||
| let find_map t ~f = find_map_from 0 t ~f | ||
|
|
||
| let insert t k v = | ||
| Dynarray.add_last t v (* Dummy insertion to expand *); | ||
| for i = Dynarray.length t - 1 downto k + 1 do | ||
| Dynarray.set t i (Dynarray.get t (pred i)) | ||
| done; | ||
| Dynarray.set t k v | ||
|
|
||
| let remove (type a) (t : a t) k = | ||
| for i = k to Dynarray.length t - 2 do | ||
| Dynarray.set t i (Dynarray.get t (succ i)) | ||
| done; | ||
| ignore (Dynarray.pop_last t : a) | ||
|
|
||
| let get_exn = get | ||
| let get = `shadowed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| include Vector | ||
|
|
||
| let iter ~f t = iter f t | ||
|
|
||
| let iteri_from ~f i t = | ||
| for i = i to length t - 1 do | ||
| f i (unsafe_get t i) | ||
| done | ||
|
|
||
| let rec find_map_from i t ~f = | ||
| if i >= length t then None | ||
| else | ||
| let a = unsafe_get t i in | ||
| match f a with Some _ as some -> some | None -> find_map_from (i + 1) t ~f | ||
|
|
||
| let find_map t ~f = find_map_from 0 t ~f | ||
|
|
||
| let insert t k v = | ||
| Vector.push t v (* Dummy insertion to expand *); | ||
| for i = Vector.length t - 1 downto k + 1 do | ||
| Vector.set t i (Vector.get t (pred i)) | ||
| done; | ||
| Vector.set t k v | ||
|
|
||
| let remove (type a) (t : a t) k = | ||
| for i = k to Vector.length t - 2 do | ||
| Vector.set t i (Vector.get t (succ i)) | ||
| done; | ||
| ignore (Vector.pop t : a) | ||
|
|
||
| let get_exn = get | ||
| let get = `shadowed |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.