Skip to content

Commit

Permalink
feat(Language): add the abbreviation id = seq [] (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia authored May 21, 2023
1 parent affe0cc commit 12ffa87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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

0 comments on commit 12ffa87

Please sign in to comment.