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 shapeless._ | |
import ops._ | |
import coproduct._ | |
object coproducttest { | |
type U = Int :+: String :+: CNil | |
type V = Double :+: List[Int] :+: CNil |
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
package fommil.polys | |
import shapeless._ | |
sealed trait Trait | |
case class Foo() extends Trait | |
case class Bar() extends Trait | |
trait Thing[T] { def thingy: String } |
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
package shapeless.examples | |
import shapeless._ | |
import nat._ | |
import ops.hlist._ | |
import test._ | |
object TableExample extends App { | |
final case class Row[L <: HList](cells: L) |
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.util.control.TailCalls._ | |
import shapeless._ | |
trait Foldable[F[_]] { | |
def foldLeft[A, B](fa: F[A], b: B)(f: (B, A) => B): B | |
} | |
object Foldable { | |
implicit def apply[F[_]](implicit fr: Lazy[FoldableRec[F]]): Foldable[F] = |
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
object FlattenTuple { | |
import shapeless._ | |
import ops.tuple.FlatMapper | |
import syntax.std.tuple._ | |
trait LowPriorityFlattenTuple extends Poly1 { | |
implicit def default[T] = at[T](Tuple1(_)) | |
} |
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 shapeless._ | |
import shapeless.poly._ | |
import shapeless.ops.hlist._ | |
import scala.util.Try | |
trait Deserializer[A, B] { | |
def apply(t: A): Either[String, B] | |
} | |
object Deserializer { |
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 org.json4s._ | |
import org.json4s.native.JsonMethods._ | |
import shapeless._ | |
import poly._ | |
import ops.hlist._ | |
import syntax.singleton._ | |
import record._ | |
object JSON { | |
def compact[A](a: A)(implicit st: toJSON.Case[A] { type Result <: JValue }): String = |
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
/* | |
- type mismatch; found : com.tagged.vor.toJSON.type required: ?{def apply(x$1: ? >: | |
A): ?} Note that implicit conversions are not applicable because they are ambiguous: | |
both method inst1 in trait PolyInst of type [A](fn: shapeless.Poly)(implicit cse: | |
fn.ProductCase[shapeless.::[A,shapeless.HNil]])A => cse.Result and macro method apply | |
in object Poly of type (f: Any)shapeless.Poly are possible conversion functions from | |
com.tagged.vor.toJSON.type to ?{def apply(x$1: ? >: A): ?} | |
- Unable to convert expression Expr[Nothing](toJSON) to a polymorphic function | |
value | |
*/ |
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
/* | |
- type mismatch; found : com.tagged.vor.toJSON.type required: ?{def apply(x$1: ? >: | |
A): ?} Note that implicit conversions are not applicable because they are ambiguous: | |
both method inst1 in trait PolyInst of type [A](fn: shapeless.Poly)(implicit cse: | |
fn.ProductCase[shapeless.::[A,shapeless.HNil]])A => cse.Result and macro method apply | |
in object Poly of type (f: Any)shapeless.Poly are possible conversion functions from | |
com.tagged.vor.toJSON.type to ?{def apply(x$1: ? >: A): ?} | |
- Unable to convert expression Expr[Nothing](toJSON) to a polymorphic function | |
value | |
*/ |
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 shapeless._ | |
// fogus wanted this: | |
// [a] -> [b] -> [a b a b ...] | |
// Follow up question: "Do you know a dependent language with my interleave?" | |
// Yes. Scala and shapeless even make it a single line! | |
trait AB[-L <: HList, A, B] |
NewerOlder