In Haskell, some Functor fmap
fmap :: (a -> b) -> f a -> f b
In TypeScript,
type F<A> = A[];
const F = // type constructor
<A>(a: A): F<A> => [a];
type map = <A, B> // function => function
(f: (a: A) => B) =>
(Fa: F<A>) => F<B>;
Similarly, in Dart, I try to implement
typedef F<A> = Map<String, A>;
typedef Fmap<A, B> = (F<B> Function(F<A>)) (Function(B Function(A)));
but the second line has errors, what would be the correct syntax?
CodePudding user response:
To be honest I have not the slightest idea what you are trying to do, since I don't get any of the two examples, but this compiles fine:
typedef F<A> = Map<String, A>;
typedef Fmap<A, B> = F<B> Function(F<A>) Function(B Function(A));