Skip to content

Commit

Permalink
Remove base dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbin committed Aug 2, 2024
1 parent 7b73c87 commit a6bab4a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 11 deletions.
4 changes: 0 additions & 4 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
(depends
(ocaml
(>= 5.2))
(base
(and
(>= v0.17)
(< v0.18)))
(bisect_ppx
(and
:dev
Expand Down
1 change: 0 additions & 1 deletion provider.opam
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ bug-reports: "https://github.com/mbarbin/provider/issues"
depends: [
"dune" {>= "3.16"}
"ocaml" {>= "5.2"}
"base" {>= "v0.17" & < "v0.18"}
"bisect_ppx" {dev & >= "2.8.3"}
"ppx_js_style" {dev & >= "v0.17" & < "v0.18"}
"sexplib0" {>= "v0.17" & < "v0.18"}
Expand Down
4 changes: 2 additions & 2 deletions src/dune
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(library
(name provider)
(public_name provider)
(flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Base)
(libraries base)
(flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Sexplib0)
(libraries sexplib0)
(instrumentation
(backend bisect_ppx))
(lint
Expand Down
23 changes: 23 additions & 0 deletions src/import.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
let phys_equal = ( == )

module Array = struct
include ArrayLabels

let for_alli =
let rec loop t ~f i =
if i = length t then true else if f i t.(i) then loop t ~f (i + 1) else false
in
fun t ~f -> loop t ~f 0
;;
end

module List = ListLabels

module Ordering = struct
type t =
| Equal
| Less
| Greater

let of_int i = if i < 0 then Less else if i = 0 then Equal else Greater
end
20 changes: 20 additions & 0 deletions src/import.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
val phys_equal : 'a -> 'a -> bool

module Array : sig
include module type of ArrayLabels

val for_alli : 'a array -> f:(int -> 'a -> bool) -> bool
end

module List : sig
include module type of ListLabels
end

module Ordering : sig
type t =
| Equal
| Less
| Greater

val of_int : int -> t
end
10 changes: 6 additions & 4 deletions src/provider.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open! Import

exception E of Sexp.t

let () =
Expand Down Expand Up @@ -87,7 +89,7 @@ module Interface = struct
let make (type a) (implementations : a Trait.Implementation.t list) : (a, _) t =
let implementations =
implementations
|> List.stable_sort ~compare:Trait.Implementation.compare_by_uid
|> List.stable_sort ~cmp:Trait.Implementation.compare_by_uid
|> dedup_sorted_keep_last ~cmp:Trait.Implementation.compare_by_uid
in
match implementations with
Expand Down Expand Up @@ -189,7 +191,7 @@ module Interface = struct
~trait
~update_cache:true
~if_not_found:If_not_found.raise
~if_found:Fn.id
~if_found:Fun.id
;;

let lookup_opt t ~trait =
Expand All @@ -198,7 +200,7 @@ module Interface = struct
~trait
~update_cache:true
~if_not_found:If_not_found.none
~if_found:Option.return
~if_found:Option.some
;;

let implements t ~trait =
Expand All @@ -209,7 +211,7 @@ module Interface = struct
~trait
~update_cache:false
~if_not_found:If_not_found.false_
~if_found:(Fn.const true)
~if_found:(Fun.const true)
;;
end

Expand Down

0 comments on commit a6bab4a

Please sign in to comment.