Conversation

Right. But it seems weird and hacky to me that the otherwise polymorphic List.map apparently has two types: ('a -> 'b) -> 'a list -> 'b list and (('a -> 'b * 'a list) -> 'b list. Can Reason programmers define functions with Curried or not pairs of types? Eek.
2
That's not a pair. You might have misunderstood the syntax change. No type definition/semantic has changed
1
I'm a big fan of Reason. But you're right that I'm not understanding. I want to write an unCurried version of map and the usual Curried one. The former is: let rec map = (f, xs) => switch xs { | [] => [] | [x, ...xs] => [f(x), ... map(f, xs)] }; What is the latter?
2
Coders want the flexibility of deciding whether or not a function they define is Curried or is unCurried. Sometimes they want one, sometimes they want the other. If my example was implicitly Curried, how to define one that's actually unCurried? I want type errors when I screw up.
2
Sure. (* map : ('a -> 'b) -> 'a list -> 'b list *) let rec map f xs = match xs with | [] -> [] | x :: xs -> f x :: map f xs (* mapUC : (('a -> 'b * 'a list) -> 'b list *) let rec mapUC (f, xs) = match xs with | [] -> [] | x :: xs -> f x :: mapUC (f, xs)
3
Yup. It’s still rooted in LC just like OCaml is. It’s just that the syntax makes LC more familiar. The semantics have not changed in the slightest. The AST hasn’t even changed - only the concrete syntax has.
1
1
It's just very weird and confusing that the concrete syntax has changed in a way that makes it harder to grok the actual semantics of what is going on. I get there are problems with currying, but this is just going to confuse the situation even more. 😫
1
2
Show replies