pub enum LambdaType {
A,
E,
T,
Composition(Box<LambdaType>, Box<LambdaType>),
}Expand description
The basic type system of the lambda calculus and LOT.
Variants§
A
A type for crate::Actors
E
A type for crate::Events
T
A type for truth values.
Composition(Box<LambdaType>, Box<LambdaType>)
A type for functions
Implementations§
Source§impl LambdaType
impl LambdaType
Sourcepub fn lift_type(self) -> LambdaType
pub fn lift_type(self) -> LambdaType
Takes a type x and returns <<x,t>, t>
Sourcepub fn retrievable_types(&self) -> RetrievableTypeIterator<'_> ⓘ
pub fn retrievable_types(&self) -> RetrievableTypeIterator<'_> ⓘ
Get all types which can be created from this type (what you would need to pass before to produce that type).
§Examples
- <a,t> can create t (arg: a)
- <a,<a,t>> can create t: (arg: a) or <a,t> (arg: a)
- <a, <<a,t>, <t,t>>> can create <<a,t>, <t,t>> (arg: a), <t,t> (arg: <a,t>) or t
let x = LambdaType::from_string("<a, <<a,t>, <t,t>>>")?
.retrievable_types()
.map(|(_, x)| x.to_string())
.collect::<Vec<_>>();
assert_eq!(x, vec!["<<a,t>,<t,t>>", "<t,t>", "t"]);Sourcepub fn is_lifted_type_of(&self, t: &LambdaType) -> bool
pub fn is_lifted_type_of(&self, t: &LambdaType) -> bool
Checks if the type is the lifted version of another.
Sourcepub fn add_right_argument(&mut self, other: LambdaType)
pub fn add_right_argument(&mut self, other: LambdaType)
Takes a type t and argument x and returns <t, x>
Sourcepub fn add_left_argument(&mut self, other: LambdaType)
pub fn add_left_argument(&mut self, other: LambdaType)
Takes a type t and argument x and returns <x, t>
Sourcepub fn from_string(s: &str) -> Result<Self, TypeParsingError>
pub fn from_string(s: &str) -> Result<Self, TypeParsingError>
Parse a type
let x = LambdaType::from_string("<e,<e,t>>")?;§Errors
Returns a TypeParsingError if the string is malformed and doesn’t represent a type.
Sourcepub fn split(&self) -> Result<(&LambdaType, &LambdaType), TypeError>
pub fn split(&self) -> Result<(&LambdaType, &LambdaType), TypeError>
Sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Checks that the type is a function.
Sourcepub fn is_one_place_function(&self) -> bool
pub fn is_one_place_function(&self) -> bool
Checks if the type takes a primitive type and returns a primitive type
Source§impl LambdaType
impl LambdaType
Sourcepub fn random_no_e(r: &mut impl Rng) -> Self
pub fn random_no_e(r: &mut impl Rng) -> Self
Returns a random type, except for LambdaType::E
Trait Implementations§
Source§impl Clone for LambdaType
impl Clone for LambdaType
Source§fn clone(&self) -> LambdaType
fn clone(&self) -> LambdaType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LambdaType
impl Debug for LambdaType
Source§impl Default for LambdaType
impl Default for LambdaType
Source§fn default() -> LambdaType
fn default() -> LambdaType
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for LambdaType
impl<'de> Deserialize<'de> for LambdaType
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for LambdaType
impl Display for LambdaType
Source§impl From<ActorOrEvent> for LambdaType
impl From<ActorOrEvent> for LambdaType
Source§fn from(value: ActorOrEvent) -> Self
fn from(value: ActorOrEvent) -> Self
Converts to this type from the input type.
Source§impl Hash for LambdaType
impl Hash for LambdaType
Source§impl Ord for LambdaType
impl Ord for LambdaType
Source§fn cmp(&self, other: &LambdaType) -> Ordering
fn cmp(&self, other: &LambdaType) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for LambdaType
impl PartialEq for LambdaType
Source§impl PartialOrd for LambdaType
impl PartialOrd for LambdaType
Source§impl Serialize for LambdaType
impl Serialize for LambdaType
impl Eq for LambdaType
impl StructuralPartialEq for LambdaType
Auto Trait Implementations§
impl Freeze for LambdaType
impl RefUnwindSafe for LambdaType
impl Send for LambdaType
impl Sync for LambdaType
impl Unpin for LambdaType
impl UnwindSafe for LambdaType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
An iterator over the items within this container, by reference.
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
Check whether an item is contained within this sequence.
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
Convert an item of the sequence into a [
MaybeRef].