Skip to content

Instantly share code, notes, and snippets.

@non
Last active August 29, 2015 14:02
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 non/800d395284c5f3f5d3c7 to your computer and use it in GitHub Desktop.
Save non/800d395284c5f3f5d3c7 to your computer and use it in GitHub Desktop.
Attempt to use kind-projector to support @mandubian's use case as presented here: https://gist.github.com/mandubian/55f8b1fb9f9bec2c0a99
package xyz
import language.higherKinds
import scalaz._
import Scalaz._
import scala.concurrent.Future
// see https://github.com/non/kind-projector for more info about what is going on here
object Test {
// consumes a type *
def type0[U]: Int = 0
// consumes a type * -> *
def type1[U[_]]: Int = 1
// OptionT part
type1[({ type L[B] = OptionT[Future, B] })#L]
type1[OptionT[Future, ?]]
// ListT part
type1[({ type M[A] = ListT[({ type L[+B] = OptionT[Future, B] })#L, A] })#M]
type1[({ type M[A] = ListT[Lambda[+[B] => OptionT[Future, B]], A] })#M]
type1[({ type M[A] = ListT[OptionT[Future, +?], A] })#M]
type1[Lambda[A => ListT[OptionT[Future, +?], A]]]
type1[ListT[OptionT[Future, +?], ?]]
// MonadPlus part
type0[MonadPlus[ListT[OptionT[Future, +?], ?]]]
}
@non
Copy link
Author

non commented Jun 6, 2014

I think this is the first "in-the-wild" use of the covariance/contravariance support I added awhile ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment