Skip to content

Commit 67751eb

Browse files
authored
Merge pull request #76 from CakeML/typeclassLang
2 parents 0311f57 + 37e451c commit 67751eb

28 files changed

+21601
-0
lines changed

.github/workflows/pure.yml

+4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ jobs:
116116
run: cd pure/compiler/backend/languages/properties && Holmake
117117
- name: Build typing
118118
run: cd pure/typing && Holmake
119+
- name: Build typeclass/typing
120+
run: cd pure/typeclass/typing && Holmake
121+
- name: Build typeclass/compiler/parsing
122+
run: cd pure/typeclass/compiler/parsing && Holmake
119123
- name: Build compiler/backend/passes
120124
run: cd pure/compiler/backend/passes && Holmake
121125
- name: Build compiler/backend/passes/proofs

Holmakefile

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ INCLUDES = misc\
88
compiler/backend/languages/properties\
99
compiler/backend/languages/relations\
1010
typing\
11+
typeclass/compiler/parsing\
12+
typeclass/typing\
1113
compiler/backend/passes\
1214
compiler/backend/passes/proofs\
1315
compiler/parsing\

typeclass/Holmakefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ifndef CAKEMLDIR
2+
CAKEMLDIR = $(HOME)/cakeml/master
3+
endif
4+
5+
INCLUDES = $(CAKEMLDIR)/basis/pure \
6+
$(PUREDIR)/misc \
7+
$(HOLDIR)/examples/algorithms \
8+
$(PUREDIR)/typeclass/typing \
9+
$(PUREDIR)/typeclass/compiler/parsing \
10+

typeclass/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# TypeclassLang
2+
3+
This is a language that support type classes. The file structure is similar to pure.
4+
- compiler/parsing: contains the AST for typeclassLang and defines how the AST is translated to TypeclassLang. The lexer and parser is not done yet.
5+
- typing: It contains all the typing related stuffs
6+
- `typeclass_types`: We update the datatype for types to allow types like `m a`.
7+
- `typeclass_kindCheck`: This defines the kinding rules.
8+
- `typeclass_typing`: This translates TypeclassLang to pureLang. It defines the type elaborating relation and the dictionary construction relation (We split the relation in the original paper into two relations). The ie parameter in the relations is generated from the `class_map` and `inst_list`. It also contains how types and environment is translated when typeclassLang is translated to pureLang.
9+
- `test_typeclass_typing`: This is an example that types a program in TypeclassLang and translates it to pureLang.
10+
- `pure_tcexp_typing`: This defines the typing rules for tcexp. We need to change the typing rules because we need to allow constructors like `MonadDict (forall a. m a -> (a -> m a) -> m a)` to make the type translation proof work.
11+
- `typeclass_typingProof`: This proves the if the expression in typeclassLang is well-typed, and we can construct the dictionaries, then the translated expression in pureLang is well-typed.
12+
- `pure_tcexp_typingProof`: This proves the type soundness of the typing relation defined in `pure_tcexp_typing`. The `NestedCase` is still WIP.
13+
- `typeclass_env_map_impl`: This defines the concreate data structures for classes and instances. It defines some well-formedness conditions. It also defines `by_super`, `by_inst` and `entail` (an implementation of `has_dict`), which should be useful for inferencing.
14+
15+
TODO:
16+
- type soundness proof (`NestedCase` case)
17+
- parsing: lexer, parser and well-formedness check
18+
- concrete implementation of dictionary construction
19+
- type inferencing
20+
- kind inferencing
21+

typeclass/compiler/parsing/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
parsing-selftest.log
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ifndef CAKEMLDIR
2+
CAKEMLDIR = $(HOME)/cakeml/master
3+
endif
4+
5+
INCLUDES = $(HOLDIR)/examples/formal-languages/context-free \
6+
$(CAKEMLDIR)/semantics \
7+
$(CAKEMLDIR)/basis/pure \
8+
$(PUREDIR)/typeclass/typing \
9+
$(PUREDIR)/misc/
10+
11+
HOLHEAP = $(CAKEMLDIR)/misc/cakeml-heap
12+
13+
all: $(DEFAULT_TARGETS)
14+
15+
.PHONY: all
16+

0 commit comments

Comments
 (0)