-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
## Indexed Data | ||
|
||
The key idea of indexed data is to encode type equalities in data. | ||
When we come to inspect the data (usually, via structural recursion) we discover these equalities, which in turn limit what values we can produce. | ||
Notice, again, the duality with codata. | ||
Indexed codata limits methods we can call. | ||
Indexed data limits values we can produce. | ||
Also, remember that indexed data is often known as generalized algebraic data types. | ||
We are using the simpler term indexed data to emphasise the relationship to indexed codata, | ||
and also because it's much easier to type! | ||
|
||
Let's see a simple, and classic, example: evaluating a small language. | ||
Our language will have basic arithmetic as well as conditionals, which is just enough to make it interesting. | ||
We'll start with the version without indexed data. | ||
|
||
```scala mdoc:silent | ||
enum Expr { | ||
case | ||
} | ||
``` |