'Type for `|f| move |A| A.map(f)`

My previous QA

What is the type for |x| move |y| x + y?

Thanks to the provided answer, the following code works.

  #![feature(type_alias_impl_trait)]

  type Adder = impl Fn(isize) -> isize;
  type Plus = fn(isize) -> Adder;
  let plus: Plus = |x| move |y| x + y;
  println!("{}", plus(9)(1)); //10

Based on this, now I try to re-define map Functor.

  #![feature(type_alias_impl_trait)]

  type Mapper<A, B> = impl Fn(Vec<A>) -> Vec<B>;
  type Map = <A, B>(fn(fn(A) -> B) -> Mapper<A, B>);

  let map:Map = |f| move |A| A.map(f);

  let f = |a| a * 2;
  let A = vec![1, 2, 3];
  let B = map(f)(A);

However, the first line got an error: could not find defining uses, the second line, for <A, B> syntax error.

Is it possible to fix this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source