Perhaps they should both be forced to pretty-print to
`List.map((x) => x * x, [2, 3]) |> Js.log;`
to remove any ambiguity (they both print to the same OCaml now reasonml.github.io/try/?reason=DI)
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
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
We didn't introduce new uncurrying semantics. It's just a syntax change. Your example is still implicitly curried:
1
1
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
Can you show an explicit comparative example of what you mean in OCaml? Curious how it’s different.
1
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
See here: twitter.com/reasonml/statu
Emphasis: it's a syntax change, the type system is untouched and there's no syntax ambiguity
1
1
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. 😫
Have you thought about having a transitional Reason syntax for beginners, then encourage people to move to the more transparently curried version as they get a handle on things?
1
1
Show replies




