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<'a>(&'a self) -> RetrievableTypeIterator<'a> ⓘ
pub fn retrievable_types<'a>(&'a self) -> RetrievableTypeIterator<'a> ⓘ
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>>")?;Sourcepub fn split(&self) -> Result<(&LambdaType, &LambdaType), TypeError>
pub fn split(&self) -> Result<(&LambdaType, &LambdaType), TypeError>
Split a function type into input and output. Returns a TypeError if the type is not a
function.
Sourcepub fn apply(&self, other: &Self) -> Result<&Self, TypeError>
pub fn apply(&self, other: &Self) -> Result<&Self, TypeError>
Applies a function type to self. Returns a TypeError if the type is not the right type
for the function.
Sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Checks that the type is a function.
Sourcepub fn lhs(&self) -> Result<&Self, TypeError>
pub fn lhs(&self) -> Result<&Self, TypeError>
Get the left-hand side of a function. Returns a TypeError if the type is not 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
Trait Implementations§
Source§impl Clone for LambdaType
impl Clone for LambdaType
Source§fn clone(&self) -> LambdaType
fn clone(&self) -> LambdaType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
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
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,
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
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
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>
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>
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
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§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,
MaybeRef].