puffnfresh/roy

Remove "where"?

Opened this issue · 2 comments

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 removing let (in favor of just foo bar = baz with no let keyword needed).

Can we confirm the decision to drop where? If so, I can push removing both where and let.

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.