Macro polytype::arrow [] [src]

macro_rules! arrow {
    [$x:expr] => { ... };
    [$x:expr, $($xs:expr),*] => { ... };
    [$x:expr, $($xs:expr,)*] => { ... };
}

Creates a Type::Arrow of tp0 → tp1 → ... (convenience for nested arrows).

This is equivalent to:

Be careful when using this code, it's not being tested!
Type::Arrow(Arrow {
    arg: Box::new(tp0),
    ret: Box::new(Type::Arrow(Arrow {
        arg: Box::new(tp1),
        ret: Box::new(Type::Arrow(Arrow {
            arg: Box::new(tp2),
            ...
        })),
    })),
})

Examples

#[macro_use] extern crate polytype;
use polytype::{Arrow, Type};

let t = arrow![Type::Variable(0), Type::Variable(1), Type::Variable(2)];
assert_eq!(format!("{}", t), "t0 → t1 → t2");
// equivalent to:
let t_eq = Type::Arrow(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!(t, t_eq);