Type-checking code for the Grace Programming Language from Pomona College.
Node.js is a prerequisite to use Grace. At the time when this document was written, version v10.15.3 was being used.
To install Grace, clone the git repository mentioned below, change your directory to be the newly created StaticTyping folder, and then run the chmod command as shown below:
git clone https://github.com/KimBruce/StaticTyping.git
cd StaticTyping
chmod +x install-minigrace.sh
./install-minigrace.shOpen the .bash_profile, and set the GRACE_MODULE_PATH to /usr/local/lib/grace/modules and the directory StaticTyping on your machine.
To compile after any changes are made to the static typing files, change your directory into the StaticTyping folder and run a make or make compile command.
To run all the tests at once, you can run the make test command in the StaticTyping directory.
- Dialects
- Traits
- Generic constraints
- Standard grace objects from prelude (currently hard coded)
- Generics without constraints
- Subtyping
- & and variant types using normal form
- Imports
- Generics
- Chained (imports of imports)
We could not figure out how to use StaticTyping dialect alongside a user-defined dialect. We tried two different approaches:
- Create a
hasTypecheckboolean field inutil.graceand set it to true when--typecheckoption is present. Then, incompiler.grace, ifhasTypecheckis true, call the visitor fromStaticTyping.grace. The issue we had with this approach is thatmgcwas not able to locateStaticTyping.js. - Manually combine a user-defined dialect and
StaticTyping.gracein a single.gracefile.
We have not implemented subtyping optimization. That is, a type Number | String | Number should reduce to Number | String type, but currently does not. Our proposed changes can be found in TODO comment in method | in ObjectTypeModule.grace.
We have implemented a representation of embedded types, but have decided not to commit that change since the language specification does not allow types inside types. That code can be found here. The main changes include adding types method to anObjectType and types parameter to fromMethods method in ObjectTypeModule.grace.