Skip to content
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

feat(Language): add the abbreviation id = seq [] #106

Merged
merged 1 commit into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Language.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ let except p = in_ p none
let renaming p p' = M_seq [M_in (p, M_assert_nonempty); M_renaming (p, p')]

let seq ms = M_seq ms
let id = seq []

let hook f = M_hook f

Expand Down
10 changes: 8 additions & 2 deletions src/LanguageSigs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ sig
(** {2 Basics} *)

(** [any] keeps the content of the current tree. It is an error if the tree is empty (no name to match).
To avoid the emptiness checking, use the identity modifier {!val:seq}[ []].
To avoid the emptiness checking, use the identity modifier {!val:id}.
This is equivalent to {!val:only}[ []]. *)
val any : 'hook t

(** [id] is {!val:seq}[ []], which keeps the content of the current tree.
This is different from {!val:any} because [id] does not check whether the tree is empty while {!val:any} does.

@since 5.0.0 *)
val id : 'hook t

(** [only path] keeps the subtree rooted at [path]. It is an error if the subtree was empty. *)
val only : Trie.path -> 'hook t

Expand All @@ -43,7 +49,7 @@ sig
(** {2 Sequencing} *)

(** [seq [m0; m1; m2; ...; mn]] runs the modifiers [m0], [m1], [m2], ..., [mn] in order.
In particular, [seq []] is the identity modifier. *)
In particular, [seq []] is the identity modifier {!val:id}. *)
val seq : 'hook t list -> 'hook t

(** {2 Union} *)
Expand Down