Skip to content

Commit

Permalink
A bit more on indexed data
Browse files Browse the repository at this point in the history
  • Loading branch information
noelwelsh committed Dec 17, 2024
1 parent 552c865 commit f36a386
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/pages/indexed-types/data.md
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
}
```

0 comments on commit f36a386

Please sign in to comment.