Skip to content

Commit

Permalink
Add Seq.is_empty in compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Halbaroth committed Nov 8, 2023
1 parent bb62ec3 commit 2f4a6cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/structures/modelMap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module Graph = struct
let rec aux ppf seq =
match seq () with
| Seq.Nil -> ()
| Cons (args, seq) when Seq.is_empty seq ->
| Cons (args, seq) when Compat.Seq.is_empty seq ->
Fmt.pf ppf "%a" (pp_args 0) args
| Cons (args, seq) ->
Fmt.pf ppf "(or %a %a)"
Expand All @@ -140,7 +140,7 @@ module Graph = struct
let rec aux ppf seq =
match seq () with
| Seq.Nil -> ()
| Cons ((ret_val, _), seq) when Seq.is_empty seq ->
| Cons ((ret_val, _), seq) when Compat.Seq.is_empty seq ->
Fmt.pf ppf "%a" Value.pp ret_val
| Cons ((ret_val, fiber), seq) ->
Fmt.pf ppf "(@[<hv>ite %a@ %a@ %a)@]"
Expand Down
7 changes: 7 additions & 0 deletions src/lib/util/compat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ module Seq = struct

open Stdlib.Seq

let is_empty xs =
match xs() with
| Nil ->
true
| Cons (_, _) ->
false

let rec append xs ys () =
match xs () with
| Nil -> ys ()
Expand Down
3 changes: 3 additions & 0 deletions src/lib/util/compat.mli
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ end
module Seq : sig
type 'a t = 'a Stdlib.Seq.t

(* @since 4.14.0 *)
val is_empty : 'a t -> bool

(* @since 4.11.0 *)
val append : 'a t -> 'a t -> 'a t
end

0 comments on commit 2f4a6cc

Please sign in to comment.