Struct polytype::Arrow [] [src]

pub struct Arrow {
    pub arg: Type,
    pub ret: Type,
}

A curried function.

Examples

use polytype::{Type, Arrow};

let func = Arrow{
    arg: Type::Variable(0),
    ret: Type::Arrow(Box::new(Arrow{
        arg: Type::Variable(1),
        ret: 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 From<Arrow> for Type
[src]

[src]

Performs the conversion.

impl Debug for Arrow
[src]

[src]

Formats the value using the given formatter. Read more

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]

Auto Trait Implementations

impl Send for Arrow

impl Sync for Arrow