1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#[macro_export] macro_rules! natural_transformation { ( { $( $field:ident : $field_type:ty ),* $(,)? } ; $name:ident : forall x . $f1:ty [@x] -> $f2:ty [@x] ; ($arg:ident) => $body:expr ) => { { struct $name <'a> { $( $field : &'a $field_type ),* _phantom : &'a () } impl <'a> $crate::internal::functional::NaturalTransformation < $f1, $f2 > for $name<'a> { fn lift < A > ( &self, $arg: App < $f1, A > ) -> App < $f2, A > where A: Send + 'static { $body } } &$name{ $( $field : &$field ),* _phantom: &() } } } }