Struct polytype::Arrow
[−]
[src]
pub struct Arrow {
pub arg: Box<Type>,
pub ret: Box<Type>,
}A curried function.
Examples
use polytype::{Type, Arrow}; let func = Arrow{ arg: Box::new(Type::Variable(0)), ret: Box::new(Type::Arrow(Arrow{ arg: Box::new(Type::Variable(1)), ret: Box::new(Type::Variable(2)), })), }; assert_eq!(Vec::from(func.args()), vec![&Type::Variable(0), &Type::Variable(1)]); assert_eq!(func.returns(), &Type::Variable(2));
With the macros:
let func = arrow![tp!(0), tp!(1), tp!(2)]; if let Type::Arrow(arr) = func { assert_eq!(Vec::from(arr.args()), vec![&tp!(0), &tp!(1)]); assert_eq!(arr.returns(), &tp!(2)); } else { unreachable!() } // we know func is an arrow
Fields
arg: Box<Type>
ret: Box<Type>
Methods
impl Arrow[src]
fn args(&self) -> VecDeque<&Type>[src]
Get all arguments to the function, recursing through curried functions.
fn returns(&self) -> &Type[src]
Get the return type of the function, recursing through curried function returns.
Trait Implementations
impl Debug for Arrow[src]
impl Clone for Arrow[src]
fn clone(&self) -> Arrow[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more