Skip to content

Instantly share code, notes, and snippets.

@mandubian
Last active November 13, 2017 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mandubian/feeecaa875899a060372a8c4fa6efe58 to your computer and use it in GitHub Desktop.
Save mandubian/feeecaa875899a060372a8c4fa6efe58 to your computer and use it in GitHub Desktop.
// our CCC with Graph as morphism
implicit val GraphCCC: ClosedCartesianCat[Graph] = new ClosedCartesianCat[Graph] {
// long boring useless code
}
// we can also implement CCCNumExt for Graph
implicit def GraphCCCNumExt[A](implicit N: Numeric[A], gp: GenPorts[A]): CCCNumExt[Graph, A] = new CCCNumExt[Graph, A] {
// genComp just generate a component with 2 inputs, 1 output and a nice name
def negateC: Graph[A, A] = genComp("-")
def addC: Graph[(A, A), A] = genComp("+")
def mulC: Graph[(A, A), A] = genComp("*")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment