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

Methods

impl Arrow
[src]

[src]

Get all arguments to the function, recursing through curried functions.

[src]

Get the return type of the function, recursing through curried function returns.

Trait Implementations

impl Debug for Arrow
[src]

[src]

Formats the value using the given formatter.

impl Clone for Arrow
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Hash for Arrow
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialEq for Arrow
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for Arrow
[src]