Skip to content

Commit 03dd0eb

Browse files
committed
update: integrate comments.
1 parent a6abccd commit 03dd0eb

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Documentation
66

7-
- [compiler](./docs/compiler.md)
7+
- [Compiler](./docs/compiler.md)
88

99
## Getting started
1010

docs/compiler.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ Similarly, the _Compiler Output_ is also a _proto_ that is then consumed by
1616
_Codegen_ modules, able to be written in any programming environment capable of
1717
communicating via Google Protocol Buffers.
1818

19-
## Checking type definitions
19+
## Checking Type Definitions
2020

2121
The primary purpose of the compiler is to typecheck the schemata that users
2222
define via the _Frontend_. The schemata terms are ADT declarations and their
2323
types are kinds.
2424

25-
Currently the schema language supports:
25+
Currently the schema language _Compiler_ supports:
2626

27-
1. types (such as `Int` or `Bool`),
27+
1. type terms of kind `Type` (such as `Int` or `Bool`),
2828

29-
2. and type functions (such as `Maybe` or `Either`).
29+
2. and type function terms of kind `Type → Type` (such as `Maybe` or `Either`).
3030

3131
There are future plans to expand this to Higher Kinded Types (such as `MaybeT`,
3232
`StateT` etc.) - subject to research into _Codegen_ of such types in the target
@@ -37,28 +37,27 @@ Schemata terms must be monomorphically kinded, with polymorphic kinds defaulting
3737
to monomorphic ones. For example `Phantom a = Phantom` would resolve to the
3838
monomorphic kind `Type → Type` rather than the polymorphic kind `∀a. a → Type`.
3939

40-
<!-- cstml comments: Is this true? I think it's an Aim not a requirement?
41-
:todo: -->
40+
## Checking Type Cardinality
4241

43-
In addition to typechecking, the compiler must perform a special check for
44-
recursive types: It must validate that a recursive type is inhabited (or
45-
inhabitable). The purpose of this check is to ensure that any schema which
46-
passes validation is (in principle) a schema for which type definitions and
47-
typeclass "instances" (which may be simple functions in languages without
48-
typeclass support) can be generated. As an example, the compiler should reject
49-
types such as `data F a = F (F a)`, which is uninhabited.
42+
In addition to typechecking, the compiler could perform a special check for
43+
recursive types, namely: a check to see if a recursive type is inhabited. The
44+
purpose of this check is to ensure that any schema which passes validation is
45+
(in principle) a schema for which type definitions and typeclass "instances"
46+
(which may be simple functions in languages without typeclass support) can be
47+
generated. As an example, the compiler should be able to reject types such as
48+
`data F a = F (F a)`, which is uninhabited. This is an additional feature that
49+
we're currently reviewing.
5050

51-
<!-- cstml comments: Is this true? Seems as though this should fail
52-
parsing. :todo: -->
51+
## Normalising Type Definitions
5352

54-
(Provisional:) Finally, the compiler should _normalize_ expressions as far as it
55-
is able to. For example, it may be possible to define a data type in the schema
56-
language in a form similar to: `data G a = G ((Either) ((Maybe) a) Int)`, where
57-
the parentheses indicate application. Ideally, this would be normalized to `data
58-
G a = G (Either (Maybe a) Int)` to result in cleaner (and more performant) code
59-
generation.
53+
Finally, the compiler should be able to _normalise_ expressions. For example, it
54+
may be possible to define a data type in the schema language in a form similar
55+
to: `data G a = G ((Either) ((Maybe) a) Int)`, where the bracketing indicates
56+
the order of application within the term. The example term would normalise to
57+
`data G a = G (Either (Maybe a) Int)` - resulting in a cleaner (and more
58+
performant) code generation.
6059

61-
## Checking type class definitions and instance clauses
60+
## Checking Typeclass Definitions and Instance Clauses
6261

6362
The _Compiler_ should, if possible, ensure that all instance declarations for
6463
schemata are derivable using hard-coded derivation axioms. Because the checks
@@ -69,3 +68,6 @@ when the design of the typeclass system has been fleshed out more.
6968
## Unsolved Problems
7069

7170
- [ ] How do we represent recursive types in our lambda calculus AST?
71+
72+
- [ ] How would cardinality checking be integrated within our current checking
73+
strategy?

0 commit comments

Comments
 (0)