|
|
|
|
|
by simiones
2147 days ago
|
|
So in the end, as I claimed initially, this function can't be written in a simple, safe way in Haskell; and as the article I linked claims, Haskell's type system can't encode the type of the cl_map function. It's nice that Haskell does offer a way to circumvent the type system to write somewhat dynamic code, but it's a shame that in order to write a relatively simple function we need to resort to that. Note that the type of cl_map is perfectly static. It would be `Integer N => (a_0 ->... a_N -> r) -> [a_0] ->... [a_N] -> [r]` assuming some fictitious syntax. |
|
Steady on! You posed a question and I gave an answer. You weren't happy with that answer. I think it's a bit premature to conclude that "this function can't be written in a simple, safe way in Haskell".
> as the article I linked claims, Haskell's type system can't encode the type of the cl_map function.
Could you say where you see that claim in the article? I can see three mentions of "Haskell" in the body, two of them mentioning that one researcher's particular implementation doesn't handle this case, but not a claim that it can't be done.
> Note that the type of cl_map is perfectly static. It would be `Integer N => (a_0 ->... a_N -> r) -> [a_0] ->... [a_N] -> [r]` assuming some fictitious syntax.
OK, fine, it's a bit clearer now what you are looking for. How about this:
Notice that the function arguments are have different, statically-known types! The type of this miracle function? And the implementation? Given that the only two lines that actually matter are and the rest are boiler plate that could be auto-derived, I think this is pretty satisfactory. What do you think?