Skip to content

Commit

Permalink
Merge pull request #42 from mbarbin/abstract-traits
Browse files Browse the repository at this point in the history
Abstract traits constructors
  • Loading branch information
mbarbin authored Oct 30, 2024
2 parents 6c961d8 + fa3ad94 commit 39d9313
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 88 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: ci

on:
- pull_request
- push
push:
branches:
- main
pull_request:
branches:
- "**" # This will match pull requests targeting any branch

jobs:
build:
Expand All @@ -27,8 +31,8 @@ jobs:
opam-repositories: |
default: https://github.com/ocaml/opam-repository.git
mbarbin: https://github.com/mbarbin/opam-repository.git
# janestreet-bleeding: https://github.com/janestreet/opam-repository.git
# janestreet-bleeding-external: https://github.com/janestreet/opam-repository.git#external-packages
# janestreet-bleeding: https://github.com/janestreet/opam-repository.git
# janestreet-bleeding-external: https://github.com/janestreet/opam-repository.git#external-packages

- name: Install dependencies
run: opam install . --deps-only --with-doc --with-test --with-dev-setup
Expand All @@ -38,8 +42,8 @@ jobs:

- name: Run tests
run: |
mkdir $BISECT_DIR
opam exec -- dune runtest --instrument-with bisect_ppx
mkdir $BISECT_DIR
opam exec -- dune runtest --instrument-with bisect_ppx
env:
BISECT_DIR: ${{ runner.temp }}/_bisect_ppx_data
BISECT_FILE: ${{ runner.temp }}/_bisect_ppx_data/data
Expand Down
14 changes: 14 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 0.0.10 (unreleased)

### Added

### Changed

- Abstract the trait type constructors (PR, @mbarbin).

### Deprecated

### Fixed

### Removed

## 0.0.9 (2024-10-23)

### Added
Expand Down
4 changes: 2 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
(cmdlang-cmdliner-runner
(>= 0.0.5))
(cmdliner
(= 1.3.0))
(>= 1.3.0))
(eio
(>= 1.0))
(eio_main
Expand Down Expand Up @@ -258,7 +258,7 @@
(cmdlang-to-cmdliner
(>= 0.0.5))
(cmdliner
(= 1.3.0))
(>= 1.3.0))
(core
(and
(>= v0.17)
Expand Down
90 changes: 70 additions & 20 deletions lib/vcs/src/trait.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,118 +24,168 @@ and add_ty

module Add = struct
module type S = Trait_add.S

type (_, _, _) Provider.Trait.t +=
| Add : ('t, (module S with type t = 't), [> add ]) Provider.Trait.t

let t = Add
end

type branch = [ `Branch of branch_ty ]
and branch_ty

module Branch = struct
module type S = Trait_branch.S

type (_, _, _) Provider.Trait.t +=
| Branch : ('t, (module S with type t = 't), [> branch ]) Provider.Trait.t

let t = Branch
end

type commit = [ `Commit of commit_ty ]
and commit_ty

module Commit = struct
module type S = Trait_commit.S

type (_, _, _) Provider.Trait.t +=
| Commit : ('t, (module S with type t = 't), [> commit ]) Provider.Trait.t

let t = Commit
end

type config = [ `Config of config_ty ]
and config_ty

module Config = struct
module type S = Trait_config.S

type (_, _, _) Provider.Trait.t +=
| Config : ('t, (module S with type t = 't), [> config ]) Provider.Trait.t

let t = Config
end

type file_system = [ `File_system of file_system_ty ]
and file_system_ty

module File_system = struct
module type S = Trait_file_system.S

type (_, _, _) Provider.Trait.t +=
| File_system : ('t, (module S with type t = 't), [> file_system ]) Provider.Trait.t

let t = File_system
end

type git = [ `Git of git_ty ]
and git_ty

module Git = struct
module type S = Trait_git.S

type (_, _, _) Provider.Trait.t +=
| Git : ('t, (module S with type t = 't), [> git ]) Provider.Trait.t

let t = Git
end

type init = [ `Init of init_ty ]
and init_ty

module Init = struct
module type S = Trait_init.S

type (_, _, _) Provider.Trait.t +=
| Init : ('t, (module S with type t = 't), [> init ]) Provider.Trait.t

let t = Init
end

type log = [ `Log of log_ty ]
and log_ty

module Log = struct
module type S = Trait_log.S

type (_, _, _) Provider.Trait.t +=
| Log : ('t, (module S with type t = 't), [> log ]) Provider.Trait.t

let t = Log
end

type ls_files = [ `Ls_files of ls_files_ty ]
and ls_files_ty

module Ls_files = struct
module type S = Trait_ls_files.S

type (_, _, _) Provider.Trait.t +=
| Ls_files : ('t, (module S with type t = 't), [> ls_files ]) Provider.Trait.t

let t = Ls_files
end

type name_status = [ `Name_status of name_status_ty ]
and name_status_ty

module Name_status = struct
module type S = Trait_name_status.S

type (_, _, _) Provider.Trait.t +=
| Name_status : ('t, (module S with type t = 't), [> name_status ]) Provider.Trait.t

let t = Name_status
end

type num_status = [ `Num_status of num_status_ty ]
and num_status_ty

module Num_status = struct
module type S = Trait_num_status.S

type (_, _, _) Provider.Trait.t +=
| Num_status : ('t, (module S with type t = 't), [> num_status ]) Provider.Trait.t

let t = Num_status
end

type refs = [ `Refs of refs_ty ]
and refs_ty

module Refs = struct
module type S = Trait_refs.S

type (_, _, _) Provider.Trait.t +=
| Refs : ('t, (module S with type t = 't), [> refs ]) Provider.Trait.t

let t = Refs
end

type rev_parse = [ `Rev_parse of rev_parse_ty ]
and rev_parse_ty

module Rev_parse = struct
module type S = Trait_rev_parse.S

type (_, _, _) Provider.Trait.t +=
| Rev_parse : ('t, (module S with type t = 't), [> rev_parse ]) Provider.Trait.t

let t = Rev_parse
end

type show = [ `Show of show_ty ]
and show_ty

module Show = struct
module type S = Trait_show.S
end

type (_, _, _) Provider.Trait.t +=
| Add : ('t, (module Add.S with type t = 't), [> add ]) Provider.Trait.t
| Branch : ('t, (module Branch.S with type t = 't), [> branch ]) Provider.Trait.t
| Commit : ('t, (module Commit.S with type t = 't), [> commit ]) Provider.Trait.t
| Config : ('t, (module Config.S with type t = 't), [> config ]) Provider.Trait.t
| File_system :
('t, (module File_system.S with type t = 't), [> file_system ]) Provider.Trait.t
| Git : ('t, (module Git.S with type t = 't), [> git ]) Provider.Trait.t
| Init : ('t, (module Init.S with type t = 't), [> init ]) Provider.Trait.t
| Log : ('t, (module Log.S with type t = 't), [> log ]) Provider.Trait.t
| Ls_files : ('t, (module Ls_files.S with type t = 't), [> ls_files ]) Provider.Trait.t
| Name_status :
('t, (module Name_status.S with type t = 't), [> name_status ]) Provider.Trait.t
| Num_status :
('t, (module Num_status.S with type t = 't), [> num_status ]) Provider.Trait.t
| Refs : ('t, (module Refs.S with type t = 't), [> refs ]) Provider.Trait.t
| Rev_parse :
('t, (module Rev_parse.S with type t = 't), [> rev_parse ]) Provider.Trait.t
| Show : ('t, (module Show.S with type t = 't), [> show ]) Provider.Trait.t
type (_, _, _) Provider.Trait.t +=
| Show : ('t, (module S with type t = 't), [> show ]) Provider.Trait.t

let t = Show
end

type t =
[ add
Expand Down
Loading

0 comments on commit 39d9313

Please sign in to comment.