Skip to content

[BREAKING CHANGES] Rename Ok,Err and Remove :Result attribute and more.#2

Merged
kfly8 merged 7 commits intomainfrom
change-interface
Apr 18, 2025
Merged

[BREAKING CHANGES] Rename Ok,Err and Remove :Result attribute and more.#2
kfly8 merged 7 commits intomainfrom
change-interface

Conversation

@kfly8
Copy link
Copy Markdown
Owner

@kfly8 kfly8 commented Apr 18, 2025

This pull requests produces these things:

  1. Rename Ok,Err to ok,err
  2. Remove :Result attribute, Added result_for function
  3. Use @EXPORT_OK to export ok, err and result_for
  4. Change default value of $ENV{RESULT_SIMPLE_CHECK_ENABLED}
  5. Added unsafe_unwrap, unsafe_unwrap_err
  6. Added alias features

1. Rename Ok,Err to ok,err

I think Ok and Err does not align perl conventions. In perl, we usually use snake case. So I renamed function names.

2. Remove :Result attribute, Added result_for function

It is hard to control attribute and it has bugs like this:

use Result::Simple qw(ok err); # => It fails to import :Result attribute

So, I added result_for function, it is simple wrapper for function:

result_for div => Int, ErrorMessage;

sub div {
   my ($x, $y) = @_;
   if ($y == 0) {
      return err("Division by zero");
   }
  return ok ($x / $y);
}

3. Use @EXPORT_OK to export ok, err and result_for

It would be better to specify which functions are to be imported.

4. Change default value of $ENV{RESULT_SIMPLE_CHECK_ENABLED}

Changed to check values by default. Whatever the initial value, it is better to specify this environment variable in the production environment to prevent unexpected accidents.

5. Added unsafe_unwrap, unsafe_unwrap_err

These are utility test functions.

6. Added alias features

use Result::Simple 
   ok => { -as => 'left' },
   err => { -as => 'right' };

kfly8 added 5 commits April 18, 2025 15:13
1. Rename `Ok`,`Err` to `ok`,`err`
    - naming to better align with Perl conventions.
2. Remove :Result attribute, Added `result_for` function
    - `use Result::Simple qw(ok err)` fails to import :Result attribute
    - It is hard to control attribute, so added just result_for
      function.
3. Use @EXPORT_OK to export `ok`, `err` and `result_for`
@kfly8 kfly8 self-assigned this Apr 18, 2025
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 18, 2025

Pull Request Test Coverage Report for Build 14531989382

Details

  • 32 of 32 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 12041917785: 0.0%
Covered Lines: 78
Relevant Lines: 78

💛 - Coveralls

@kfly8 kfly8 merged commit 09f4bfa into main Apr 18, 2025
28 checks passed
kfly8 added a commit that referenced this pull request Apr 18, 2025
Changelog diff is:

diff --git a/Changes b/Changes
index 48f3529..aab3655 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,15 @@ Revision history for Perl extension Result-Simple
 
 {{$NEXT}}
 
+0.04 2025-04-18T22:53:43Z
+    - [BREAKING CHANGES]
+        - Renamed `Ok` to `ok`, `Err` to `err` #2
+        - Removed `:Result` attribute, instead added `result_for` function #2
+        - Changed default value of `$ENV{RESULT_SIMPLE_CHECK_ENABLED}` to `1` #2
+    - [ENHANCEMENTS]
+        - Added `unsafe_unwrap` and `unsafe_unwrap_err` functions #2
+        - Added `chain` and `pipeline` helper functions #3
+
 0.03 2024-11-27T01:18:40Z
     - Improve docs #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants