ekmett / ekmett/adjunctions

Isomorphism `f (Rep r)` and `r ~> f`

Open
#75 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
45
Forks
26
PR merge metrics
No merged PRs in 30d

Description

There is an isomorphism between `f (Rep r)` and natural transformations `r ~> f`:

```haskell
one :: RepresentableOf rep r => Functor f => f rep -> r ~> f
one fins as = index as <$> fins

two :: RepresentableOf rep r => (r ~> f) -> f rep
two make = make positions

positions :: RepresentableOf rep r => r rep
positions = tabulate id
```

I don't know that it's useful, but there could be some `Iso' (f rep) (r ~> f)`.

I got the idea of this isomorphism from [Cofree Traversable Functors](https://uu.diva-portal.org/smash/get/diva2:1369180/FULLTEXT01.pdf), where it is instantiated at `RepresentableOf (Fin n) (Vec n)`. I'm curious if there is deeper history.

```haskell
forall x. x -> .. (n-times) .. x -> f x
= Vec n ~> f
= f (Fin n)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.