Open rtfeldman opened 10 years ago
Can we infer types of mutually recursive (possibly polymorphic) functions without where
?
For example, is_even
and is_odd
below are mutually recursive functions having a type Number → Number
while id
is a polymorphic function having a type #a → #a
.
let f x =
is_even x
where
is_even x = if id (x == 0) then true else is_odd (id (x - 1))
is_odd x = if id (x == 0) then false else is_even (id (x - 1))
id x = x
If we can, I don't oppose dropping where
.
Yeah, as @taku0 points out. This isn't just syntactic sugar. It provides a version of polymorphism that works with mutually recursive functions, written by @taku0.
I haven't ported it over to the constraint type system but I might now be able to make it work without the where
keyword.
Not sure.
There was a mention in chat of the idea that
where
was on its way out. Personally I like the idea from a simplification standpoint, but separately,where
is the only obstacle remaining before I can push removinglet
(in favor of justfoo bar = baz
with nolet
keyword needed).Can we confirm the decision to drop
where
? If so, I can push removing bothwhere
andlet
.