(module main)

(import std.vec_bool (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range))

(fn imported_empty_length () -> i32
  (len (empty)))

(fn imported_pair_index () -> bool
  (at (pair true false) 1))

(fn original_len_after_append () -> i32
  (let values (vec bool) (empty))
  (let more (vec bool) (append values true))
  (len values))

(fn option_bool_is_some_value ((value (option bool)) (expected bool)) -> bool
  (if (is_some value)
    (= (unwrap_some value) expected)
    false))

(fn option_i32_is_some_value ((value (option i32)) (expected i32)) -> bool
  (if (is_some value)
    (= (unwrap_some value) expected)
    false))

(fn imported_builder_helpers_ok () -> bool
  (if (= (len (singleton true)) 1)
    (if (= (len (append2 (empty) true false)) 2)
      (if (= (len (append3 (singleton true) false true false)) 4)
        (if (= (pair true false) (append2 (empty) true false))
          (= (triple true false true) (append3 (empty) true false true))
          false)
        false)
      false)
    false))

(fn imported_query_helpers_ok () -> bool
  (if (is_empty (empty))
    (if (= (first_or (empty) true) true)
      (if (= (first_or (pair false true) true) false)
        (if (= (last_or (triple true false false) true) false)
          (if (= (index_or (pair true false) -1 true) true)
            (if (= (index_or (pair true false) 9 true) true)
              (= (index_or (pair true false) 1 true) false)
              false)
            false)
          false)
        false)
      false)
    false))

(fn imported_option_query_helpers_ok () -> bool
  (let repeated (vec bool) (append3 (pair true false) true false true))
  (if (is_none (first_option (empty)))
    (if (option_bool_is_some_value (first_option (pair true false)) true)
      (if (is_none (last_option (empty)))
        (if (option_bool_is_some_value (last_option (triple true false false)) false)
          (if (is_none (index_option (pair true false) -1))
            (if (is_none (index_option (pair true false) 9))
              (if (option_bool_is_some_value (index_option (pair true false) 1) false)
                (if (is_none (index_of_option (empty) true))
                  (if (option_i32_is_some_value (index_of_option repeated false) 1)
                    (if (is_none (last_index_of_option (empty) false))
                      (option_i32_is_some_value (last_index_of_option repeated false) 3)
                      false)
                    false)
                  false)
                false)
              false)
            false)
          false)
        false)
      false)
    false))

(fn imported_starts_with_helper_ok () -> bool
  (let values (vec bool) (append2 (triple true false true) false true))
  (let prefix (vec bool) (pair true false))
  (let longer_prefix (vec bool) (append2 values true false))
  (let mismatched_prefix (vec bool) (pair false true))
  (if (starts_with values (empty))
    (if (starts_with values prefix)
      (if (starts_with values values)
        (if (starts_with values longer_prefix)
          false
          (if (starts_with values mismatched_prefix)
            false
            (if (= values (append2 (triple true false true) false true))
              (= prefix (pair true false))
              false)))
        false)
      false)
    false))

(fn imported_ends_with_helper_ok () -> bool
  (let values (vec bool) (append2 (triple true false true) false true))
  (let suffix (vec bool) (pair false true))
  (let longer_suffix (vec bool) (append2 values true false))
  (let mismatched_suffix (vec bool) (pair false false))
  (if (ends_with values (empty))
    (if (ends_with values suffix)
      (if (ends_with values values)
        (if (ends_with values longer_suffix)
          false
          (if (ends_with values mismatched_suffix)
            false
            (if (= values (append2 (triple true false true) false true))
              (= suffix (pair false true))
              false)))
        false)
      false)
    false))

(fn imported_without_suffix_helper_ok () -> bool
  (let values (vec bool) (append2 (triple true false true) false true))
  (let suffix (vec bool) (pair false true))
  (let longer_suffix (vec bool) (append2 values true false))
  (let mismatched_suffix (vec bool) (pair false false))
  (if (= (without_suffix values (empty)) values)
    (if (= (without_suffix values values) (empty))
      (if (= (without_suffix values suffix) (triple true false true))
        (if (= (without_suffix values longer_suffix) values)
          (if (= (without_suffix values mismatched_suffix) values)
            (if (= values (append2 (triple true false true) false true))
              (= suffix (pair false true))
              false)
            false)
          false)
        false)
      false)
    false))

(fn imported_without_prefix_helper_ok () -> bool
  (let values (vec bool) (append2 (triple true false true) false true))
  (let prefix (vec bool) (pair true false))
  (let longer_prefix (vec bool) (append2 values true false))
  (let mismatched_prefix (vec bool) (pair true true))
  (if (= (without_prefix values (empty)) values)
    (if (= (without_prefix values values) (empty))
      (if (= (without_prefix values prefix) (triple true false true))
        (if (= (without_prefix values longer_prefix) values)
          (if (= (without_prefix values mismatched_prefix) values)
            (if (= values (append2 (triple true false true) false true))
              (= prefix (pair true false))
              false)
            false)
          false)
        false)
      false)
    false))

(fn imported_transform_helpers_ok () -> bool
  (if (= (concat (empty) (pair true false)) (pair true false))
    (if (= (concat (pair true false) (triple false true false)) (append3 (pair true false) false true false))
      (if (= (take (triple true false true) -4) (empty))
        (if (= (take (triple true false true) 2) (pair true false))
          (if (= (take (pair true false) 9) (pair true false))
            (if (= (drop (triple true false true) -4) (triple true false true))
              (if (= (drop (triple true false true) 2) (singleton true))
                (if (= (drop (pair true false) 9) (empty))
                  (if (= (reverse (empty)) (empty))
                    (= (reverse (triple true false false)) (triple false false true))
                    false)
                  false)
                false)
              false)
            false)
          false)
        false)
      false)
    false))

(fn imported_subvec_helper_ok () -> bool
  (let original (vec bool) (append2 (triple true false true) false true))
  (if (= (subvec original -1 2) (empty))
    (if (= (subvec original 3 3) (empty))
      (if (= (subvec original 9 10) (empty))
        (if (= (subvec original 2 99) (triple true false true))
          (if (= (subvec original 1 4) (triple false true false))
            (= original (append2 (triple true false true) false true))
            false)
          false)
        false)
      false)
    false))

(fn imported_insert_helper_ok () -> bool
  (let values (vec bool) (triple true false true))
  (if (= (insert_at values 1 false) (append2 (pair true false) false true))
    (if (= (insert_at values 3 false) (append values false))
      (if (= values (triple true false true))
        (if (= (insert_at values -1 false) values)
          (= (insert_at values 4 false) values)
          false)
        false)
      false)
    false))

(fn imported_insert_range_helper_ok () -> bool
  (let values (vec bool) (append2 (triple true false true) false true))
  (let inserted (vec bool) (pair false false))
  (if (= (insert_range values -1 inserted) values)
    (if (= (insert_range values 2 inserted) (append3 (append2 (pair true false) false false) true false true))
      (if (= (insert_range values 5 inserted) (append2 (append2 (triple true false true) false true) false false))
        (if (= values (append2 (triple true false true) false true))
          (if (= inserted (pair false false))
            (= (insert_range values 6 inserted) values)
            false)
          false)
        false)
      false)
    false))

(fn imported_replace_helper_ok () -> bool
  (if (= (replace_at (triple true false true) 1 true) (triple true true true))
    (if (= (replace_at (triple true false true) -1 true) (triple true false true))
      (= (replace_at (pair true false) 2 true) (pair true false))
      false)
    false))

(fn imported_replace_range_helper_ok () -> bool
  (let original (vec bool) (append2 (triple true false true) false true))
  (let replacement (vec bool) (pair false false))
  (if (= (replace_range original -1 2 replacement) original)
    (if (= (replace_range original 3 3 replacement) original)
      (if (= (replace_range original 4 2 replacement) original)
        (if (= (replace_range original 5 9 replacement) original)
          (if (= (replace_range original 2 99 replacement) (append2 (pair true false) false false))
            (if (= (replace_range original 1 4 replacement) (append2 (pair true false) false true))
              (if (= original (append2 (triple true false true) false true))
                (= replacement (pair false false))
                false)
              false)
            false)
          false)
        false)
      false)
    false))

(fn imported_remove_helper_ok () -> bool
  (let original (vec bool) (triple true false true))
  (let removed_middle (vec bool) (remove_at original 1))
  (if (= removed_middle (pair true true))
    (if (= (len removed_middle) 2)
      (if (= (remove_at original 0) (pair false true))
        (if (= (remove_at original 2) (pair true false))
          (if (= original (triple true false true))
            (if (= (remove_at original -1) original)
              (= (remove_at original 3) original)
              false)
            false)
          false)
        false)
      false)
    false))

(fn imported_remove_range_helper_ok () -> bool
  (let original (vec bool) (append2 (triple true false true) false true))
  (if (= (remove_range original -1 2) original)
    (if (= (remove_range original 3 3) original)
      (if (= (remove_range original 4 2) original)
        (if (= (remove_range original 5 9) original)
          (if (= (remove_range original 2 99) (pair true false))
            (if (= (remove_range original 1 4) (pair true true))
              (= original (append2 (triple true false true) false true))
              false)
            false)
          false)
        false)
      false)
    false))

(fn imported_real_program_helpers_ok () -> bool
  (let values (vec bool) (append2 (triple true false true) true true))
  (if (= (original_len_after_append) 0)
    (if (contains values true)
      (if (contains values false)
        (if (= (count_of values true) 4)
          (= (count_of values false) 1)
          false)
        false)
      false)
    false))

(fn helpers_all_ok () -> bool
  (if (= (imported_empty_length) 0)
    (if (= (imported_pair_index) false)
      (if (imported_builder_helpers_ok)
        (if (imported_query_helpers_ok)
          (if (imported_option_query_helpers_ok)
            (if (imported_starts_with_helper_ok)
              (if (imported_ends_with_helper_ok)
                (if (imported_without_suffix_helper_ok)
                  (if (imported_without_prefix_helper_ok)
                    (if (imported_transform_helpers_ok)
                      (if (imported_subvec_helper_ok)
                        (if (imported_insert_helper_ok)
                          (if (imported_insert_range_helper_ok)
                            (if (imported_replace_helper_ok)
                              (if (imported_replace_range_helper_ok)
                                (if (imported_remove_helper_ok)
                                  (if (imported_remove_range_helper_ok)
                                    (imported_real_program_helpers_ok)
                                    false)
                                  false)
                                false)
                              false)
                            false)
                          false)
                        false)
                      false)
                    false)
                  false)
                false)
              false)
            false)
          false)
        false)
      false)
    false))

(test "explicit std vec_bool empty len facade"
  (= (imported_empty_length) 0))

(test "explicit std vec_bool direct at facade"
  (= (imported_pair_index) false))

(test "explicit std vec_bool builder helpers"
  (imported_builder_helpers_ok))

(test "explicit std vec_bool query helpers"
  (imported_query_helpers_ok))

(test "explicit std vec_bool option query helpers"
  (imported_option_query_helpers_ok))

(test "explicit std vec_bool starts_with helper"
  (imported_starts_with_helper_ok))

(test "explicit std vec_bool ends_with helper"
  (imported_ends_with_helper_ok))

(test "explicit std vec_bool without_suffix helper"
  (imported_without_suffix_helper_ok))

(test "explicit std vec_bool without_prefix helper"
  (imported_without_prefix_helper_ok))

(test "explicit std vec_bool transform helpers"
  (imported_transform_helpers_ok))

(test "explicit std vec_bool subvec helper"
  (imported_subvec_helper_ok))

(test "explicit std vec_bool insert helper"
  (imported_insert_helper_ok))

(test "explicit std vec_bool insert range helper"
  (imported_insert_range_helper_ok))

(test "explicit std vec_bool replace helper"
  (imported_replace_helper_ok))

(test "explicit std vec_bool replace range helper"
  (imported_replace_range_helper_ok))

(test "explicit std vec_bool remove helper"
  (imported_remove_helper_ok))

(test "explicit std vec_bool remove range helper"
  (imported_remove_range_helper_ok))

(test "explicit std vec_bool real program helpers"
  (imported_real_program_helpers_ok))

(test "explicit std vec_bool helpers all"
  (helpers_all_ok))

(fn main () -> i32
  (if (helpers_all_ok)
    42
    1))
