gelisam / klister

an implementation of stuck macros
BSD 3-Clause "New" or "Revised" License
132 stars 11 forks source link

wrap `data` to support datatype names with no parentheses #185

Open gelisam opened 1 year ago

gelisam commented 1 year ago

I would like to be able to write

(data Nat
  (zero)
  (suc Nat))

instead of

(data (Nat)
  (zero)
  (suc (Nat)))

Currently, stdlib/builtins.kl defines the appropriate wrappers so that we can write (the Bool (true)) instead of (the (Bool) (true). It would be nice if that syntax was supported out of the box for user-defined datatypes as well. This sounds easy to implement, by defining a Prelude data macro wrapping the kernel's data macro.

gelisam commented 1 year ago

In this ticket, I am specifically not asking about supporting (true) instead of true, because I know that the parentheses-free syntax is not supported in patterns. I think the parentheses-free syntax should be fine in type-case patterns because we already have many primitive types which don't need parentheses.