@@ -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
1717communicating via Google Protocol Buffers.
1818
19- ## Checking type definitions
19+ ## Checking Type Definitions
2020
2121The primary purpose of the compiler is to typecheck the schemata that users
2222define via the _ Frontend_ . The schemata terms are ADT declarations and their
2323types 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
3131There 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
3737to monomorphic ones. For example ` Phantom a = Phantom ` would resolve to the
3838monomorphic 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
6362The _ Compiler_ should, if possible, ensure that all instance declarations for
6463schemata 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