Last active
December 18, 2015 08:09
-
-
Save nuttycom/5751479 to your computer and use it in GitHub Desktop.
A hypothesis as to what functors, monads, etc. might look like if the value type were not universally quantified, but instead could be restricted by requirement for other typeclass instances. Universal quantification could still be achieved, of course; hence this provides a more flexible generalization of our familiar typeclasses. This grew out …
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
trait Functorial[F[_], B] { | |
def map[A](m: F[A])(f: A => B): F[B] | |
} | |
trait Monadic[M[_], B] extends Functorial[F, B] { | |
def point(b: B): M[B] | |
def flatMap[A](m: M[A])(f: A => M[B]): M[B] | |
} | |
trait Traversial[F[_], B] { | |
def traverse[G[_], A](m: F[A])(f: A => G[B]): G[F[B]] | |
} | |
object SetFunctorial { | |
sealed trait SetConstruction[A] | |
case class HashSetConstruction[A](eql: Equal[A], hsh: Hashable[A]) extends SetConstruction[A] | |
case class TreeSetConstruaction[A](ord: Order[A]) extends SetConstruction[A] | |
implicit def setEqual(s: Set[A]) = new Equal[A] { | |
def equal(a0: A, a1: A) = (s + a0).contains(a1) | |
} | |
implicit def setFunctorial[B: SetConstruction]: Functorial[Set, B] = new Functorial[Set, B] { | |
def map[A](m: Set[A])(f: A => B): Set[B] = { | |
sys.error("todo") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment