|
|
|
|
|
by gavinray
1613 days ago
|
|
Scala 3 is the only "functional" language that made me not feel like an idiot, and it's great for understanding "Dependent Types" as a layman. It gives the example of a key in a database, which can return multiple types of values: type DB = (k: Key) => Option[k.Value]
Where the type of "Key" is: trait Key { type Value }
You can declare generic values of type "Key[Value]" and attempting to look them up in the DB can result in more than one kind of type, dependent on the value being looked up.https://docs.scala-lang.org/scala3/book/types-dependent-func... |
|
[1] Taken from https://www.idris-lang.org/pages/example.html