Experimenting/playing with Constrained Categories in Scala. Inspired by:
- Compiling to Categories by Conal Elliot
concat
library in Haskell by Conal Elliot- Blog post by Pascal Voitot on Compiling to Cartesian Closed Categories
Currently only has some core typeclasses (using ScalaZ 8 encoding), so don't expect much yet. About all one can do with it is write functions directly in the CCC encoding and execute using Function1
category.
Example using Ammonite:
@ import tf._, TF._
import tf._, TF._
@ val f = implicitly[CCC[Function1]]
f: CCC[Function1] = tf.cat.CCCInstances$$anon$1@3cf70afa
@ val e = implicitly[NumCat[Function1, Int]]
e: NumCat[Function1, Int] = tf.cat.NumCatInstances$$anon$1@7dbe858f
@ import f._, e._
import f._, e._
@ def plusC = plus ○ (exl[Int, Int] ap exr[Int, Int])
defined function plusC
@ plusC(0, 0)
res5: Int = 0
Note: you can start the Amm repl using: mill -i "core[2.12.6].repl"
Builds are defined using Mill.