Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: More detailed introduction for Option and Result #15

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

skarllot
Copy link
Contributor

  • More detailed introduction for Option and Result

present.
The `Option` type encapsulates an optional value in a way that explicitly represents either the presence
(represented as `Some`) or absence (represented as `None`) of a value. It can be used to replace nullable types
and to deal with errors or exceptional cases without resorting to drastic measures such as throwing exceptions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure about emphasizing error handling as a feature of Option, it’s really just a type-safe alternative to nullable types. Maybe describe how its simpler than for example dealing with potential nulls for reference types and default values for value types? Option lets you treat them the same, it doesn’t care whether its a reference or a value type.

What do you think?

Copy link
Contributor Author

@skarllot skarllot Jun 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that the second sentence should be dropped?

Haskell documentation define Maybe as an error monad: https://hackage.haskell.org/package/base-4.20.0.1/docs/Data-Maybe.html

Copy link
Contributor

@jeffijoe jeffijoe Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, the text looks very close to the Haskell one, but Maybe replaced with Option. If we're going to quote the Haskell docs, we should do so with a quote block and a link.

However, I don't agree with the Haskell docs on the point of it being for error handling.

How about the following intro text:

The `Option` type is a powerful construct used to represent the presence or absence of a value. 
This type is particularly useful for eliminating null reference errors, a common source of bugs in C# applications. 

An `Option`  can be either `Some` (containing a value), or `None` (indicating the absence of a value). 
By using `Option`, developers can enforce safer code practices, making it explicit when a variable, 
property, or parameter might not have a value and requires handling both cases.

@skarllot
Copy link
Contributor Author

skarllot commented Jul 2, 2024

I've made some changes to the documentation

Copy link
Contributor

@jeffijoe jeffijoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last bit, then we're good 👍

docs/core/result.md Outdated Show resolved Hide resolved
@jeffijoe jeffijoe merged commit 9206e0f into taxfyle:main Jul 2, 2024
2 checks passed
@jeffijoe
Copy link
Contributor

jeffijoe commented Jul 2, 2024

Thanks again @skarllot ! 🙏

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