Conlang/stdlib/std/option.cl

30 lines
660 B
Common Lisp

//! The optional type, representing the presence or absence of a thing.
use super::preamble::*;
pub enum Option<T> {
Some(T),
None,
}
impl Option {
pub fn is_some(self: &Self) -> bool {
match self {
Some(_) => true,
None => false,
}
}
pub fn is_none(self: &Self) -> bool {
match self {
Some(_) => false,
None => true,
}
}
/// Maps from one option space to another
// pub fn map<U>(self: Self, f: fn(T) -> U) -> Option<U> {
// match self {
// Some(value) => Some(f(value)),
// None => None,
// }
// }
}