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:
ⓘThis example is not tested
Type::Arrow(Box::new(Arrow { arg: tp0, ret: Type::Arrow(Box::new(Arrow { arg: tp1, ret: Type::Arrow(Box::new(Arrow { arg: 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(Box::new(Arrow{ arg: Type::Variable(0), ret: Type::Arrow(Box::new(Arrow{ arg: Type::Variable(1), ret: Type::Variable(2), })), })); assert_eq!(t, t_eq);