xacid: (Default)
  import cats._

  trait Sym[F[_]] {
    def lit[A]: A => F[A] // pure

    def app[A, B]: F[A => B] => F[A] => F[B] // ap

    def lam[A, B]: (F[A] => F[B]) => F[A => B] // coap?
  }

  implicit def symm[F[_] : Bimonad]: Sym[F] =
    new Sym[F] {

      val M = Bimonad[F]

      def lit[A] = M.pure[A]

      def app[A, B] = M.ap[A, B]

      def lam[A, B] = f =>
        M.pure[A => B](a =>
          M.extract(f(M.pure(a))))
    }

  val PLUS = ((_: Int) + (_: Int)).curried

  def answer[F[_] : Sym]: F[Int => Int] = {
    val sym = implicitly[Sym[F]]
    import sym._
    lam(x => app(app(lit(PLUS))(x))(x))
  }

xacid: (Default)
import cats._
import cats.implicits._

object Ska extends App {

  case class SKI[F[_] : Applicative]() {
    def S[A, B] = Applicative[F].ap[A, B] _
    def K[A] = Applicative[F].pure[A] _
    def I[A] = identity[A] _
  }

  def Num[N: Numeric] = implicitly[Numeric[N]]
  def PLUS[N: Numeric] = (Num[N].plus _).curried

  def main[N: Numeric]: N => N = {
    val ski = SKI[N => ?]
    import ski._
    S(S(K(PLUS[N]))(I))(I)
  }

  println(main[Int].apply(21))

}
xacid: (Default)
public class JavaCartesianDualism {

    // Morphism proposition is exponent

    interface Arrow<A, B extends A> {
    }

    // Sum proposition is dependent product

    interface Sum<S, A extends S, B extends S> {
    }

    // Presumably, exponent proposition is some arrow 
    // and product proposition is some sum?

    interface Prod<A, B> extends
            Prod1<A, B>, Prod2<A, B> {
    }

    interface Prod1<A, B> {
        A _1(Prod<A, B> p);
    }

    interface Prod2<A, B> {
        B _2(Prod<A, B> p);
    }

    interface _Prod1<A, B> extends
            Arrow<Prod1<A, B>, Prod<A, B>> {
    }

    interface _Prod2<A, B> extends
            Arrow<Prod2<A, B>, Prod<A, B>> {
    }

    interface _Prod<A, B, T extends Prod<A, B>>
            extends Arrow<Prod<A, B>, T> {
    }

    interface Exp<A, B> {
        A eval(B b);
    }

    interface Curry<C, A, B> extends Exp<C, Prod<A, B>> {
        Exp<C, B> curry(A a);
    }

    interface _Curry<A, B, C> extends
            Arrow<Exp<C, Prod<A, B>>, Curry<C, A, B>> {
    }

}
xacid: (Default)
public interface JavaCocartesian {

    interface ArrowExists<A, 
      B extends A> {
    }

    interface IdExists<A> 
      extends ArrowExists<A, A> {
    }

    interface FromInitialObjectTo<A> 
      extends ArrowExists<Object, A> {
    }

    interface CoproductExists<S, 
       A extends S, B extends S> {
    }
}

JCat

Nov. 8th, 2016 02:21 am
xacid: (Default)
public interface JCat {

    interface Arrow<A, B extends A> {
    }

    interface Id<A> extends Arrow<A, A> {
    }

    interface o<A, B extends A, C extends B> 
        extends Arrow<A, C> {
    }

}

Profile

xacid: (Default)
xacid

August 2017

S M T W T F S
  123 45
67891011 12
13 141516171819
20212223242526
2728293031  

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 24th, 2017 01:57 pm
Powered by Dreamwidth Studios