From 4700c143cca0a1547bde38c3b30ad601fc93cab2 Mon Sep 17 00:00:00 2001 From: kayomn Date: Fri, 3 Mar 2023 17:09:00 +0000 Subject: [PATCH] Remove monadic functions from coral::expected --- source/coral.cpp | 7 ------- source/runtime.cpp | 2 +- source/turtle.cpp | 6 +++--- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/source/coral.cpp b/source/coral.cpp index 494ccfc..1d43c14 100755 --- a/source/coral.cpp +++ b/source/coral.cpp @@ -398,13 +398,6 @@ export namespace coral { (*reinterpret_cast(this->buffer)) = error; } - /** - * Invokes the `apply` procedure if the expected is not ok, otherwise having no side-effects. - */ - void and_then(closure const & apply) { - if (this->is_ok()) apply(*this->ok()); - } - /** * Returns the contained error as an [optional]. */ diff --git a/source/runtime.cpp b/source/runtime.cpp index f9d701f..3b18270 100644 --- a/source/runtime.cpp +++ b/source/runtime.cpp @@ -21,7 +21,7 @@ extern "C" int main(int argc, char const * const * argv) { bool is_config_loaded {false}; archive_file.read_file(config_path, [&](coral::file_reader & config_reader) { - archive_file.query_file(config_path).and_then([&](coral::file_system::file_info file_info) { + archive_file.query_file(config_path).ok().and_then([&](coral::file_system::file_info file_info) { turtle::system_allocator allocator {turtle::system_allocator::thread_safety::none}; coral::ring_buffer config_source; diff --git a/source/turtle.cpp b/source/turtle.cpp index eee9e72..ad2f034 100755 --- a/source/turtle.cpp +++ b/source/turtle.cpp @@ -402,7 +402,7 @@ export namespace turtle { void read_file(slice const & path, closure const & then) override { if (!this->access_permissions.can_read) return; - this->path.joined(path).and_then([&](native_path const & native_file_path) -> void { + this->path.joined(path).ok().and_then([&](native_path const & native_file_path) -> void { native_file file; if (file.open(native_file_path, native_file::open_mode::read_only) != open_result::ok) return; @@ -421,7 +421,7 @@ export namespace turtle { void walk_files(slice const & path, closure const & then) override { if (!this->access_permissions.can_walk) return; - this->path.joined(path).and_then([&](native_path const & native_directory_path) -> void { + this->path.joined(path).ok().and_then([&](native_path const & native_directory_path) -> void { // TODO: Implement. }); } @@ -434,7 +434,7 @@ export namespace turtle { void write_file(slice const & path, closure const & then) override { if (!this->access_permissions.can_write) return; - this->path.joined(path).and_then([&](native_path const & native_file_path) -> void { + this->path.joined(path).ok().and_then([&](native_path const & native_file_path) -> void { native_file file; if (file.open(native_file_path, native_file::open_mode::overwrite) != open_result::ok) return;