Skip to content

Commit 380412b

Browse files
committed
Discuss an alternative that makes conditional givens more like functions
1 parent 373f599 commit 380412b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

content/typeclasses-syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ As an example, the most natural reading of
651651
given [A: Ord] => Ord[List[A]]
652652
```
653653
is _if `A` is `Ord` then `List[A]` is `Ord`_, or, equivalently, `A` is `Ord` _implies_ `List[A]` is `Ord`, hence the `=>`. Another way to see this is that
654-
the given clause establishes a _context function_ of type `[A: Ord] ?=> List[Ord[A]]` that is automatically applied to evidence arguments of type `Ord[A]` and that yields instances of type `List[Ord[A]]`. Since givens are in any case applied automatically to all their arguments, we don't need to specify that separately with `?=>`, a simple `=>` arrow is sufficiently clear and is easier to read.
654+
the given clause establishes a _context function_ of type `[A: Ord] ?=> Ord[List[A]]` that is automatically applied to evidence arguments of type `Ord[A]` and that yields instances of type `Ord[List[A]]`. Since givens are in any case applied automatically to all their arguments, we don't need to specify that separately with `?=>`, a simple `=>` arrow is sufficiently clear and is easier to read.
655655

656656
Once one has internalized the analogy with implications and functions, one
657657
could argue the opposite, namely that the `=>` in a given clause is not sufficiently function-like. For instance, `given [A] => F[A]` looks like it implements a function type, but `given[A](using B[A]) => F[A]` looks like a mixture between a function type and a method signature.

0 commit comments

Comments
 (0)