Skip to content

Instantly share code, notes, and snippets.

@possiblywrong
Created February 5, 2014 12:21
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 possiblywrong/8822528 to your computer and use it in GitHub Desktop.
Save possiblywrong/8822528 to your computer and use it in GitHub Desktop.
Rough sketch
object TestCase {
trait MYtype[A]
case class Bob(i: Int) extends MYType[Int]
case class Wibble[A,B](t1: MYType[A], t2: MYType[B]) extends MYType[A\/B]
// MYType => ( List[(A,B)] => List[B] )
// So we define myfun for each member of the MYType ADT
object myfun extends Poly1 {
implicit def caseOne = at[Bob]( i => { ... somefn } )
implicit def caseTwo[A,B] = at[Wibble[A,B]]( i => { { xs => myfun(as) ++ myfun(bs) } } )
}
object somefn extends Poly1 {
implicit def caseOne[A] = at[List[(Int,A)]]( ... )
}
val t1 = myfun(Bob(42))
val t2 = myfun(Wibble(Bob(5),Bob(101)))
}
@milessabin
Copy link

I'm still not getting it ... too many '...'s in critical places. What here are you either trying to close over? Or, alternatively, what is the binary function that you'd like to partially apply?

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