Commit 244c367c authored by Adrian Cochrane's avatar Adrian Cochrane

Specify typechecking and informing server of errors.

parent 9ccf23e9
......@@ -6,6 +6,8 @@ If a file starts with `#!`, the last whitespace-seperated "word" of that line sh
This file should contain a function of the signature `parse : Func Bytes Program` or `parse : Func List Char Program`, using the standard library types.
Alternatively this function may return a `Result Program x` type. If it returns the `Error` variant the program should not run and instead the user should be informed that there's a problem and given the option to upload it's fully-resolved textual serialization to the program's (not module's) URL alongside the URL of the failing module.
### Importing files
A file may start with a comma-seperated list surrounded by square brackets of names which should be accessible to any script importing it.
......@@ -37,6 +39,33 @@ A special type named `Func` takes two type arguments and matches any function wh
### Comments
Any text on a line including and after `#` must be ignored.
## Typechecking
Prior to running a program it must be typechecked.
### Let expressions
Should resolve the types of all it's declarations, and takes on the type of it's expression.
### Match expressions
The variants matched specifies the expected type of it's inner expression, and all the branches should resolve to the same type. It's type is that of it's branches.
### Function calls
A function call's type is the return type of the called function once it's generics have been resolved. If the function doesn't have a type specified or computed it should be computed (if it isn't currently being computed) before continuing typechecking.
To resolve generic types, assume that there's a unique type parameter for each function parameter until proven otherwise.
If a variant's treated as a function, it's return type corresponds to the type declaration the variants from.
### Failing typecheck
If a program fails to typecheck, it should not run. Instead the user should be informed that the program's broken and the interpretor should offer to send a POST request to the program (not module's) URL with the following parameters:
* module
* line (optional)
* column (optional)
* expression (optional)
* expectedtype
* actualtype
* useragent
## Running a program
Each program must contain a function named `main` that takes any subset (including all or none) of the following types defined in the standard library in any order:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment