This file contains 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 test { | |
trait M[X[_]] { | |
def map[A, B](a: X[A])(f: A => B): X[B] | |
} | |
trait Parsers { | |
trait Parser[Y] { | |
def map[B](f: Y => B): Parser[B] = null | |
} | |
} |
This file contains 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
// See this mailing list thread for context: | |
// https://groups.google.com/d/topic/scala-language/ImqJuGylyi8/discussion | |
case class Companion[-C, T](t : T) | |
trait Publish[C, T] { self : T => | |
implicit val companion = Companion[C, T](this) | |
} | |
trait StaticKey { |
This file contains 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.TypeOperators._ | |
import shapeless.Record._ | |
import shapeless.BasisConstraint._ | |
import Neo4jTypesConstraints.OfNeo4jFieldsConstraint._ | |
import Neo4jTypesConstraints._ | |
import Neo4jTypes._ | |
object Neo4jTypes { |
This file contains 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 MonoidExamples { | |
import shapeless._ | |
import HList._ | |
trait Monoid[T] | |
// Boilerplate ... | |
trait HListed[S, L <: HList] | |
implicit def hl1[S[_], A] = new HListed[S[A], A :: HNil] {} | |
implicit def hl2[S[_, _], A, B] = new HListed[S[A, B], A :: B :: HNil] {} |
This file contains 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
// See http://research.microsoft.com/en-us/um/people/simonpj/papers/boxy/boxy-icfp.pdf | |
object Impredicative extends App { | |
import shapeless._ | |
import TypeOperators._ | |
object head extends (List ~> Id) { | |
def default[T](l : List[T]) = l.head | |
} | |
def g(o : Option[List ~> Id]) = o match { |
This file contains 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
// K ~?> V witnesses the existence of a natural transformation between K and V | |
class ~?>[K[_], V[_]] { | |
class λ[KT, VT] // Witness K ~?> V at a particular K[T], V[T] | |
} | |
object ~?> { | |
// To instantiate the first-order witness we need a value of the | |
// higher-kinded witness, so we depend on it implicitly | |
implicit def witness[K[_], V[_], T](implicit rel : K ~?> V) = new rel.λ[K[T], V[T]] |
This file contains 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
/* | |
* Copyright (c) 2012 Miles Sabin | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains 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
// Universal quantification is encoded in terms of quantifier-free | |
// assertions about an "abitrary" type (cp. "all swans are white" vs. | |
// "the arbitrary swan is white". Inspired by Kit Fine's 1985 "Reasoning | |
// with Arbitrary Objects", http://philosophy.fas.nyu.edu/object/kitfine. | |
// | |
// Possibly also related to Oleg Kiselyov's "Interpreting types as | |
// abstract values", http://okmij.org/ftp/Computation/index.html#teval. | |
// What I wouldn't give for kind-polymorphism here ... | |
This file contains 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
case class ZeeingEvent( | |
zid: String, | |
kind: String, | |
showId: String, | |
show_name: Option[String], | |
time: DateTime | |
) { | |
require (kind == "StartedZeeing" || kind == "EndedZeeing") | |
} |
This file contains 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.parsing.combinator._ | |
import scalaz._, Scalaz._ | |
trait ExtraStateParsers[S] { this: Parsers => | |
type ESP[A] = StateT[Parser, S, A] | |
protected implicit def monadInstance: Monad[Parser] | |
protected implicit def monadStateInstance = | |
implicitly[MonadState[({type F[T, +B] = StateT[Parser, T, B]})#F, S]] |
OlderNewer