https://github.com/snowleopard/cats
Musings on category theory
https://github.com/snowleopard/cats
Last synced: 5 months ago
JSON representation
Musings on category theory
- Host: GitHub
- URL: https://github.com/snowleopard/cats
- Owner: snowleopard
- License: mit
- Created: 2019-02-10T23:27:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-06-24T14:19:12.000Z (about 4 years ago)
- Last Synced: 2025-04-09T19:00:57.618Z (over 1 year ago)
- Language: Haskell
- Size: 20.5 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# Musings on category theory
[](https://github.com/snowleopard/cats/actions)
Nothing special, just trying to make sense of various papers and ideas involving
Category Theory.
## Compiling to Categories
Experimenting with compiling STLC to Closed Cartesian Categories.
See Conal Elliott's ICFP'17 paper
[Compiling to Categories](http://conal.net/papers/compiling-to-categories/compiling-to-categories.pdf).
Source: https://github.com/snowleopard/cats/blob/master/src/CCC.hs.
An example `ghci` session:
```haskell
λ> k = Lam $ Lam $ Var (S Z)
λ> :t k
k :: Expr c (a1 -> a2 -> a1)
λ> :t compile k
compile k :: CCC c (a1 -> a2 -> a1)
λ> pretty (compile k)
"curry (curry (snd . fst))"
```
## Matrix category
Experimenting with an inductive matrix data type that forms a category.
Source: https://github.com/snowleopard/cats/blob/master/src/Matrix.hs.
An example `ghci` session:
```haskell
λ> m = (singleton 1 ||| singleton 2) &&& (singleton 3 ||| singleton (4 :: Int))
λ> dump m
[1,2]
[3,4]
λ> dump (transpose m)
[1,3]
[2,4]
λ> dump (m . transpose m)
[5,11]
[11,25]
λ> dump ((m . transpose m) ||| id)
[5,11,1,0]
[11,25,0,1]
λ> dump $ functionN (\x y -> bool 0 (1 :: Int) (x || y))
[0,1]
[1,1]
λ> dump $ functionN (\x y -> x && y)
[False,False]
[False,True]
```