We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Looks at this program: playground
func x[A, B any](f func(A) B) func[S ~[]A](s S) []B { return nil }
The go compiler raise error: function type must have no type parameters.
function type must have no type parameters
This lead to we can't write higher order function which takes type parameter.
In the above example, we can't make the return function take a slice that underlying type is ~[]E.
~[]E
I don't want to put the type parameters into the declaration of function x, because S depends on the return function, not the function x.
x
S
Also declaring it in x forces me to specify the type parameters when calling x instead of deriving them automatically.
The text was updated successfully, but these errors were encountered:
The return depends on S, not the other way around. Plus, type inference works with partial lists. Please discuss this in the forums.
Sorry, something went wrong.
Also adding for posterity: higher order generics can very quickly make type checking undecidable, especially when adding branching.
What is the problem by writing to
func x[A, B any](f func(A) B) func([]A) []B { return nil }
No branches or pull requests
Proposal Details
Looks at this program:
playground
The go compiler raise error:
function type must have no type parameters
.This lead to we can't write higher order function which takes type parameter.
In the above example, we can't make the return function take a slice that underlying type is
~[]E
.I don't want to put the type parameters into the declaration of function
x
, becauseS
depends on the return function, not the functionx
.Also declaring it in x forces me to specify the type parameters when calling x instead of deriving them automatically.
The text was updated successfully, but these errors were encountered: