I can not find any simple and detailed source of how to add non-recursive let-expressions to pure type systems.
The best I found is the Henk paper by Simon Peyton Jones, but his explanation of this point is very brief.
Can someone link some references about this topic (source code is accepted)?
EDIT
The let
I want to add has the following syntax:
let x : T = M in N
where x
is the variable name, T
is its type, M
is the expression with which all free occurrences of x
in expression N
will be replaced. It can only introduce nested definitions, so recursion is impossible.
In untyped lambda calculus it is syntactic sugar. By analogy it should be equivalent to (λ(x : T) -> N) M
, but as you know this conversion does not type-check in PTS, so new type rules must be included.
(λ(x : T) -> N) M
type checked, even in PTS. What's the problem there? IfM
has typeT
it should work. BothM
andN
seem to be typed in the same context wrtlet
or its desugaring. Are you considering the case where the lambda builds a $\prod$ type which is outside the current PTS? Then, I might understand... $\endgroup$M
is not known when typechecking(λ(x : T) -> N)
which makes a big different withlet x = M in N
. Think of e.g.let x = 1 in refl : x = 1
.\(x : Nat) -> refl : x = 1
would be ill-typed. $\endgroup$