Skip to content

Instantly share code, notes, and snippets.

@fommil
Created November 14, 2017 22:24
Show Gist options
  • Select an option

  • Save fommil/0b5f73dc9b3821cbc9b5fb1201f077c9 to your computer and use it in GitHub Desktop.

Select an option

Save fommil/0b5f73dc9b3821cbc9b5fb1201f077c9 to your computer and use it in GitHub Desktop.

Revisions

  1. fommil created this gist Nov 14, 2017.
    30 changes: 30 additions & 0 deletions Exists.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    // Copyright: 2017 Sam Halliday
    // License: http://www.gnu.org/licenses/gpl.html
    package scalaz

    import scala.Option

    import Scalaz._

    sealed abstract class /~\[F[_], C[_]] {
    type T
    def value: C[T]
    def tc: F[T]
    }
    object /~\ {
    type Aux[F[_], C[_], A] = /~\[F, C] { type T = A }
    def unapply[F[_], C[_]](p: F /~\ C): Option[(F[p.T], C[p.T])] =
    scala.Predef.???
    def apply[F[_], A](a: A, fa: => F[A]): Aux[F, Id, A] = new /~\[F, Id] {
    type T = A
    def value: A = a
    def tc: F[A] = fa
    }
    type T2[A] = (A, A)
    def apply[F[_], A](a1: A, a2: A, fa: => F[A]): Aux[F, T2, A] =
    new /~\[F, T2] {
    type T = A
    def value: (A, A) = (a1, a2)
    def tc: F[A] = fa
    }
    }