(* Generated by coq-of-rust *)
Require Import CoqOfRust.CoqOfRust.

(* StructTuple
  {
    name := "Cardinal";
    const_params := [];
    ty_params := [];
    fields := [];
  } *)

(* StructTuple
  {
    name := "BlueJay";
    const_params := [];
    ty_params := [];
    fields := [];
  } *)

(* StructTuple
  {
    name := "Turkey";
    const_params := [];
    ty_params := [];
    fields := [];
  } *)

(* Trait *)
(* Empty module 'Red' *)

(* Trait *)
(* Empty module 'Blue' *)

Module Impl_generics_bounds_test_case_empty_bounds_Red_for_generics_bounds_test_case_empty_bounds_Cardinal.
  Definition Self : Ty.t := Ty.path "generics_bounds_test_case_empty_bounds::Cardinal".
  
  Axiom Implements :
    M.IsTraitInstance
      "generics_bounds_test_case_empty_bounds::Red"
      Self
      (* Trait polymorphic types *) []
      (* Instance *) [].
End Impl_generics_bounds_test_case_empty_bounds_Red_for_generics_bounds_test_case_empty_bounds_Cardinal.

Module Impl_generics_bounds_test_case_empty_bounds_Blue_for_generics_bounds_test_case_empty_bounds_BlueJay.
  Definition Self : Ty.t := Ty.path "generics_bounds_test_case_empty_bounds::BlueJay".
  
  Axiom Implements :
    M.IsTraitInstance
      "generics_bounds_test_case_empty_bounds::Blue"
      Self
      (* Trait polymorphic types *) []
      (* Instance *) [].
End Impl_generics_bounds_test_case_empty_bounds_Blue_for_generics_bounds_test_case_empty_bounds_BlueJay.

(*
fn red<T: Red>(_: &T) -> &'static str {
    "red"
}
*)
Definition red (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
  match ε, τ, α with
  | [], [ T ], [ β0 ] =>
    ltac:(M.monadic
      (let β0 := M.alloc (| β0 |) in
      M.match_operator (| β0, [ fun γ => ltac:(M.monadic (M.read (| Value.String "red" |))) ] |)))
  | _, _, _ => M.impossible "wrong number of arguments"
  end.

Axiom Function_red : M.IsFunction "generics_bounds_test_case_empty_bounds::red" red.

(*
fn blue<T: Blue>(_: &T) -> &'static str {
    "blue"
}
*)
Definition blue (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
  match ε, τ, α with
  | [], [ T ], [ β0 ] =>
    ltac:(M.monadic
      (let β0 := M.alloc (| β0 |) in
      M.match_operator (| β0, [ fun γ => ltac:(M.monadic (M.read (| Value.String "blue" |))) ] |)))
  | _, _, _ => M.impossible "wrong number of arguments"
  end.

Axiom Function_blue : M.IsFunction "generics_bounds_test_case_empty_bounds::blue" blue.

(*
fn main() {
    let cardinal = Cardinal;
    let blue_jay = BlueJay;
    let _turkey = Turkey;

    // `red()` won't work on a blue jay nor vice versa
    // because of the bounds.
    println!("A cardinal is {}", red(&cardinal));
    println!("A blue jay is {}", blue(&blue_jay));
    //println!("A turkey is {}", red(&_turkey));
    // ^ TODO: Try uncommenting this line.
}
*)
Definition main (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
  match ε, τ, α with
  | [], [], [] =>
    ltac:(M.monadic
      (M.read (|
        let~ cardinal :=
          M.alloc (| Value.StructTuple "generics_bounds_test_case_empty_bounds::Cardinal" [] |) in
        let~ blue_jay :=
          M.alloc (| Value.StructTuple "generics_bounds_test_case_empty_bounds::BlueJay" [] |) in
        let~ _turkey :=
          M.alloc (| Value.StructTuple "generics_bounds_test_case_empty_bounds::Turkey" [] |) in
        let~ _ :=
          let~ _ :=
            M.alloc (|
              M.call_closure (|
                M.get_function (| "std::io::stdio::_print", [] |),
                [
                  M.call_closure (|
                    M.get_associated_function (| Ty.path "core::fmt::Arguments", "new_v1", [] |),
                    [
                      M.alloc (|
                        Value.Array
                          [
                            M.read (| Value.String "A cardinal is " |);
                            M.read (| Value.String "
" |)
                          ]
                      |);
                      M.alloc (|
                        Value.Array
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.path "core::fmt::rt::Argument",
                                "new_display",
                                [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
                              |),
                              [
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "generics_bounds_test_case_empty_bounds::red",
                                      [ Ty.path "generics_bounds_test_case_empty_bounds::Cardinal" ]
                                    |),
                                    [ cardinal ]
                                  |)
                                |)
                              ]
                            |)
                          ]
                      |)
                    ]
                  |)
                ]
              |)
            |) in
          M.alloc (| Value.Tuple [] |) in
        let~ _ :=
          let~ _ :=
            M.alloc (|
              M.call_closure (|
                M.get_function (| "std::io::stdio::_print", [] |),
                [
                  M.call_closure (|
                    M.get_associated_function (| Ty.path "core::fmt::Arguments", "new_v1", [] |),
                    [
                      M.alloc (|
                        Value.Array
                          [
                            M.read (| Value.String "A blue jay is " |);
                            M.read (| Value.String "
" |)
                          ]
                      |);
                      M.alloc (|
                        Value.Array
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.path "core::fmt::rt::Argument",
                                "new_display",
                                [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
                              |),
                              [
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_function (|
                                      "generics_bounds_test_case_empty_bounds::blue",
                                      [ Ty.path "generics_bounds_test_case_empty_bounds::BlueJay" ]
                                    |),
                                    [ blue_jay ]
                                  |)
                                |)
                              ]
                            |)
                          ]
                      |)
                    ]
                  |)
                ]
              |)
            |) in
          M.alloc (| Value.Tuple [] |) in
        M.alloc (| Value.Tuple [] |)
      |)))
  | _, _, _ => M.impossible "wrong number of arguments"
  end.

Axiom Function_main : M.IsFunction "generics_bounds_test_case_empty_bounds::main" main.
