Curry Typing
Curry-style typing is a more flexible approach to assigning types in lambda calculus. Unlike Church-style typing, types are not explicitly written in the expressions but are instead inferred from the context. This makes Curry typing less strict and closer to modern functional programming languages, where type inference plays a significant role.
Basic Notation
Curry-style typing is expressed using typing judgments, written as:
where:
(the typing context) contains known type assignments. is the term being typed. is the inferred type of .
Unlike Church-style typing, types are not explicitly written in the lambda expression itself. Instead, the type of each term is derived from the context.
In Curry typing, it is common to use
Curry Typing Rules
Curry-style typing follows a set of inference rules to determine the type of expressions.
1. Variable Typing Rule
If
This means we can directly infer the type of a variable from the context.
Example:
If
2. Function Application Rule
If
Example:
If we have:
Since
3. Function Abstraction Rule
If
Example:
For the function:
we assign:
since
Typing Examples
Example 1: Identity Function
Assigning Types
- Assume
has type . - Assume
has type . - Since
returns , it has type . - Then,
has type .
✅ Final Type:
Function
Example 2: Function Application
Assigning Types
- Assume
is of type . - Assume
is of type . - Then,
results in type . - Assume
has type . - Since
means applying to , we require . - Thus,
has type .
✅ Final Type:
Why Curry Typing is More Flexible
Curry-style typing is less strict than Church-style typing because:
- It does not require explicit type annotations in lambda expressions.
- It allows type inference, meaning types are deduced from context instead of being written explicitly.
- It enables polymorphism, meaning functions can be used with multiple types.
- It is more similar to real-world functional programming languages like Haskell, where types are inferred automatically.
| Feature | Church Typing | Curry Typing |
|---|---|---|
| Explicit types | ✅ Required | ❌ Inferred |
| Type annotations | ✏️ Written in terms | 🚀 Inferred from context |
| Flexibility | ❌ More strict | ✅ More flexible |
| Common in | Formal systems, logic | Functional programming |
🚀 Curry typing is more flexible and allows implicit type inference, making it practical for programming languages!