--
For more ways to connect visit https://dart.dev/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/243b9f9f-685f-4609-9e79-6fced62a8a90n%40dartlang.org.
You could do the following:
A2 pipe2<A1, A2>(
A1 a1,
A2 Function(A1) f1,
) =>
f1(a1);
String Function(E) ask<E>() => (env) => 'hello';
String Function(E) Function<E>(String Function(E)) map(
String Function(String) f,
) =>
<E>(r) => (env) => f(r(env));
void main() {
pipe2(
ask<int>(),
map((b) => 'world')<int>,
);
}That is, to instantiate your map function with a trailing type argument without actually calling it (this is a relatively new feature).You could also lift the type parameter E, and specify a type argument like you did with ask:
A2 pipe2<A1, A2>(
A1 a1,
A2 Function(A1) f1,
) =>
f1(a1);
String Function(E) ask<E>() => (env) => 'hello';
String Function(E) Function(String Function(E)) map<E>(
String Function(String) f,
) =>
(r) => (env) => f(r(env));
void main() {
pipe2(
ask<int>(),
map<int>((b) => 'world'),
);
}The error is caused by the fact that map returns a generic function, but pipe expects a non-generic function.