• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MinaProtocol / mina / 2863

05 Nov 2024 06:20PM UTC coverage: 30.754% (-16.6%) from 47.311%
2863

push

buildkite

web-flow
Merge pull request #16296 from MinaProtocol/dkijania/more_multi_jobs

more multi jobs in CI

20276 of 65930 relevant lines covered (30.75%)

8631.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

51.85
/src/lib/mina_stdlib/nonempty_list.ml
1
open Core_kernel
9✔
2

3
(* A non-empty list is a tuple of the head and the rest (as a list) *)
4
[%%versioned
5
module Stable = struct
6
  module V1 = struct
7
    type 'a t = 'a * 'a list [@@deriving sexp, compare, equal, hash, to_yojson]
×
8
  end
9
end]
10

11
let init x xs = (x, xs)
4,160✔
12

13
let singleton x = (x, [])
4,680✔
14

15
let uncons = Fn.id
16

17
let cons x' (x, xs) = (x', x :: xs)
25,174✔
18

19
let head (x, _) = x
3,560✔
20

21
let tail (_, xs) = xs
5,560✔
22

23
let last (x, xs) = if List.is_empty xs then x else List.last_exn xs
×
24

25
let of_list_opt = function [] -> None | x :: xs -> Some (x, xs)
160✔
26

27
let tail_opt t = of_list_opt (tail t)
×
28

29
let map (x, xs) ~f = (f x, List.map ~f xs)
5,509✔
30

31
let rev (x, xs) = List.fold xs ~init:(singleton x) ~f:(Fn.flip cons)
4,280✔
32

33
(* As the Base.Container docs state, we'll add each function from C explicitly
34
 * rather than including C *)
35
module C = Container.Make (struct
36
  type nonrec 'a t = 'a t
37

38
  let fold (x, xs) ~init ~f = List.fold xs ~init:(f init x) ~f
800✔
39

40
  let iter = `Custom (fun (x, xs) ~f -> f x ; List.iter xs ~f)
2,103✔
41

42
  let length = `Define_using_fold
43
end)
44

45
[%%define_locally C.(find, find_map, iter, length, fold)]
46

47
let to_list (x, xs) = x :: xs
2,040✔
48

49
let append (x, xs) ys = (x, xs @ to_list ys)
120✔
50

51
let take (x, xs) = function
52
  | 0 ->
×
53
      None
54
  | 1 ->
×
55
      Some (x, [])
56
  | n ->
×
57
      Some (x, List.take xs (n - 1))
×
58

59
let min_elt ~compare (x, xs) =
60
  Option.value_map ~default:x (List.min_elt ~compare xs) ~f:(fun mininum ->
×
61
      if compare x mininum < 0 then x else mininum )
×
62

63
let max_elt ~compare (x, xs) =
64
  Option.value_map ~default:x (List.max_elt ~compare xs) ~f:(fun maximum ->
1,703✔
65
      if compare x maximum > 0 then x else maximum )
×
66

67
let rec iter_deferred (x, xs) ~f =
68
  let open Async_kernel in
×
69
  let%bind () = f x in
×
70
  match xs with [] -> return () | h :: t -> iter_deferred (h, t) ~f
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc