summaryrefslogtreecommitdiff
path: root/tests/coq/misc/PoloniusList.v
blob: a600deaaef444541492e9f5faf532fd058606f2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *)
(** [polonius_list] *)
Require Import Primitives.
Import Primitives.
Require Import Coq.ZArith.ZArith.
Require Import List.
Import ListNotations.
Local Open Scope Primitives_scope.
Module PoloniusList.

(** [polonius_list::List]
    Source: 'tests/src/polonius_list.rs', lines 6:0-6:16 *)
Inductive List_t (T : Type) :=
| List_Cons : T -> List_t T -> List_t T
| List_Nil : List_t T
.

Arguments List_Cons { _ }.
Arguments List_Nil { _ }.

(** [polonius_list::get_list_at_x]:
    Source: 'tests/src/polonius_list.rs', lines 16:0-16:76 *)
Fixpoint get_list_at_x
  (ls : List_t u32) (x : u32) :
  result ((List_t u32) * (List_t u32 -> result (List_t u32)))
  :=
  match ls with
  | List_Cons hd tl =>
    if hd s= x
    then Ok (List_Cons hd tl, Ok)
    else (
      p <- get_list_at_x tl x;
      let (l, get_list_at_x_back) := p in
      let back :=
        fun (ret : List_t u32) =>
          tl1 <- get_list_at_x_back ret; Ok (List_Cons hd tl1) in
      Ok (l, back))
  | List_Nil => Ok (List_Nil, Ok)
  end
.

End PoloniusList.