Skip to content

Commit 79e6b51

Browse files
committed
Section on type lambdas
1 parent d6f4088 commit 79e6b51

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

docs/docs/reference/type-lambdas.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
layout: doc-page
3+
title: "Type Lambdas"
4+
---
5+
6+
A _type lambda_ lets one express a higher-kinded type directly, without
7+
a type definition.
8+
9+
[+X, Y] => Map[Y, X]
10+
11+
For instance, the type above defines a binary type constructor, with a
12+
covariant parameter `X` and a non-variant parameter `Y`. The
13+
constructor maps arguments `S` and `T` to `Map[T, S]`. Type parameters
14+
of type lambdas can have variances and bounds. A parameterized type
15+
definition or declaration such as
16+
17+
type T[X] = (X, X)
18+
19+
is a shorthand for a plain type definition with a type-lambda as its
20+
right-hand side:
21+
22+
type T = [X] => (X, X)

docs/sidebar.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ sidebar:
77
url: docs/reference/intersection-types.html
88
- title: Union types
99
url: docs/reference/union-types.html
10+
- title: Type lambdas
11+
url: docs/reference/type-lambdas.html
1012
- title: Trait Parameters
1113
url: docs/reference/trait-parameters.html
1214
- title: Enumerations
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package typeLambdas
2+
3+
object Test {
4+
5+
type T = [+X, Y] => Map[Y, X]
6+
7+
}

0 commit comments

Comments
 (0)