aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2024-03-04 19:04:52 +0000
committerLouis Pilfold <louis@lpil.uk>2024-03-04 19:04:52 +0000
commit9a908c5e77a5fdf786326f7cd81cc16e93b16c5f (patch)
treea0e84de44db9ffa45b1ebc8cffcf125d701464e6 /src
parent4e6bc4570f23860cc8e52fdf425f74b81638ee28 (diff)
downloadgleam_stdlib-9a908c5e77a5fdf786326f7cd81cc16e93b16c5f.tar.gz
gleam_stdlib-9a908c5e77a5fdf786326f7cd81cc16e93b16c5f.zip
Document option/result
Diffstat (limited to 'src')
-rw-r--r--src/gleam/option.gleam12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gleam/option.gleam b/src/gleam/option.gleam
index 6224217..11457cf 100644
--- a/src/gleam/option.gleam
+++ b/src/gleam/option.gleam
@@ -4,6 +4,18 @@
/// This is Gleam's alternative to having a value that could be Null, as is
/// possible in some other languages.
///
+/// # `Option` and `Result`
+///
+/// In other languages failible functions may return either `Result` or
+/// `Option` depending on whether there is more information to be given about the
+/// failure. In Gleam all failible functions return `Result`, and `Nil` is used
+/// as the error if there is no extra detail to give. This consistency removes
+/// the boilerplate that would otherwise be needed to convert between `Option`
+/// and `Result` types, and makes APIs more predictable.
+///
+/// The `Option` type should only be used for taking optional values as
+/// function arguments, or for storing them in other data structures.
+///
pub type Option(a) {
Some(a)
None