-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expression type annotation vs. Declaration type annotation #73
Comments
Could you explain why you would want to do this? I’m not immediately sure why that is any more or less readable than the equivalent already available in Hackett: (def f : {Integer -> Integer}
(λ [x] x)) |
There are two reasons why we want this.
fact :: Integer -> Integer
fact 0 = 1
fact n = n * fact (n - 1) looks just like the set of mathematical equations, but putting a type annotation in between (: fact {Integer -> Integer})
(defn fact
[[0] 1]
[[n] {n * (fact {n - 1})}]) This looks better to me because it's closer to the equations I would write down in Haskell. |
I understand the sentiment of (2), since it’s “more like Haskell”, and generally, Hackett opts to be like Haskell where possible. That said, I don’t really like the idea. It’s non-local in a way that Racket macros usually aren’t unless they have to be. It also adds two ways to do the same thing, neither of which is ever really better or worse, which I think is normally bad language design. On the other hand, I think (1) is interesting. Is there perhaps some way that goal could be better served some other way? |
We can almost use the |
I don’t really understand that much about ML functors, so I’m not entirely sure what you’re doing/need to do, but it seems reasonable to want Hackett to leave behind information after partial expansion. I’ve been thinking it would be good for Hackett to expand into a small, explicitly-typed core language anyway before expanding into untyped Racket, a la GHC’s Core language, so maybe we can make |
That would be better than the current state of things. The Core- |
Similar to how
:
declarations work in Typed Racket or howid :: type
declarations work in Haskell, I want to be able to separate definitions from their type annotations like this:I have already implemented most of this (same way as Stephen and I did this in Typed Rosette), but there are some design questions left over.
The expression form of type annotation is already called
:
, and in places where both definitions and expressions are allowed, calling them both:
would be ambiguous. The expression version and the declaration version should probably have different names. In Typed Racket the declaration version is:
and the expression version isann
, but Hackett might need something different since:
is already the expression version.My preliminary implementation of this doesn't include Scoped Type Variables. I have had trouble "communicating" the scope between the type declaration form and the definition form where the scope is needed. We're working on this now. (Edit: now solved.)
The text was updated successfully, but these errors were encountered: