-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add new declaration forms that can be parsed at the REPL #1255
Conversation
In particular, we can now define operators using `let` in the same way that they can be inside modules and `where`. In addition, we allow `type` and `type constraint` definitions at the REPL, and `infix`, `infixl` and `infixr` declarations. Becase it is an error for an infix declaration to be stated without its corresponding declaration, we have added the ability to enter multiple definitions at once, separated by `;`. This is also useful for definition mutually recursive definitions using `let`.
For some reason,
|
I guess the warning is because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I am not a fan of declarations at the REPL, as one tends to end up with environments that are non-trivial to reproduce, and my personal preference is to have "read only" REPLs. I know that folks do ask for these features tough, so if someone finds it helpful I am fine with adding it.
I think we should start thinking of making DynamicEnv
a little less ad-hoc though (not in this pull request). In particular, I wonder if DynamicEnv
should be essentially a pair of an interface (i.e., static information) and a value environment (the dynamic information).
I guess what's surprising to me is that value |
Regarding |
@robdockins if I remember correctly we only report "unused" variables for types. We started doing that because sometimes mis-spelling a type, resulted in an unused type parameter (as in |
Top-level declarations that introduce type names should not generate warnings.
The syntax looks like: ``` let f : Integer -> Bool; let f x = x == 0 ``` The leading `let` is not the most beautiful, but it gets the job done and prevents parser conflicts.
In particular, we can now define operators using
let
in thesame way that they can be inside modules and
where
.In addition, we allow
type
andtype constraint
definitionsat the REPL, and
infix
,infixl
andinfixr
declarations.Becase it is an error for an infix declaration to be stated
without its corresponding declaration, we have added the ability
to enter multiple definitions at once, separated by
;
. Thisis also useful for definition mutually recursive definitions using
let
.