Open gelisam opened 1 year ago
I propose to extend the prelude.kl
language (but not the kernel) to support the following syntax in which a variable with the type Foo
can be given the anonymous name (the Foo)
(while still allowing (the Foo expr)
to act as a type ascription).
(data (Foo)
(foo Integer))
(define f (the (-> Foo Integer) ...))
(defun g ((the Foo))
(case (the Foo)
[(foo x)
(+ x (f (the Foo)))]))
A simpler alternative would be to recommend the naming convention the-foo
for variables of type Foo
, but my recommendation has the advantage that it can be extended into a syntax for specifying the type of the other arguments:
(defun f ((the Foo) (the Int n))
(case (the Foo)
[(foo x)
(+ x n)]))
It might be worth adding more syntax sugar:
(defun f (:Foo n:Int)
(case :Foo
[(foo x)
(+ x n)]))
In Haskell, if I have a variable of type
Foo
, I like to name itfoo
:But in Klister, the name
foo
is already taken by the data constructor, so I have to pick a different name:If we're going to be opinionated and recommend that Klister users use
foo
for their data constructor, I think we should also guide the user and recommend a default name for variables of typeFoo
.