This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.language.higherKinds | |
object Conditions { | |
//based on: An Introduction to Functional Programming Through Lambda Calculus | |
trait BOOL { | |
type body[e1 <: E, e2 <: E, E] <: E //select: (E, E) => E | |
} | |
trait TRUE extends BOOL { | |
type body[e1 <: E, e2 <: E, E] = e1 //true = select_first | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.language.higherKinds | |
import shapeless._ | |
import shapeless.ops.coproduct.IsCCons | |
import shapeless.ops.hlist.IsHCons | |
object PolyFunctor extends App { | |
trait TypeFunctor[F[_]] { | |
def map[A, B](fa: F[A])(f: A => B): F[B] | |
def pure[A](a: A): F[A] //for debug & test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.language.higherKinds | |
import scalaz._, Scalaz._ | |
object F_Algebra { | |
//### F-Algebra | |
//Fixed point of type constructor | |
case class Fix[F[_]](f: F[Fix[F]]) | |
type Algebra[F[_], A] = Function[F[A], A] //a morphism from F(A) to A |