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
[acyclic] --== Extracting dependencies for acyclic ==-- | |
[acyclic] Fetching https://github.com/lihaoyi/acyclic.git | |
[acyclic] into /home/miles/projects/community-builds/clones-0.9.5/245e354ad2399f7a8e44b501df16710d5ca8e18e-acyclic | |
[acyclic] Took: 00h 00m 00.4s | |
[acyclic] Cloning /home/miles/projects/community-builds/clones-0.9.5/245e354ad2399f7a8e44b501df16710d5ca8e18e-acyclic | |
[acyclic] to /home/miles/projects/community-builds/target-0.9.5/extraction/d4f22467376ec652fb03d6c58593ba6d267adf39/projects/73e1fbbb9c28dd54a52679838829b3b71d4f9386 | |
[acyclic] Took: 00h 00m 00.0s | |
[acyclic] Fetching /home/miles/projects/community-builds/clones-0.9.5/245e354ad2399f7a8e44b501df16710d5ca8e18e-acyclic | |
[acyclic] into /home/miles/projects/community-builds/target-0.9.5/extraction/d4f22467376ec652fb03d6c58593ba6d267adf39/projects/73e1fbbb9c28dd54a52679838829b3b71d4f9386 | |
[acyclic] Took: 00h 00m 00.0s |
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
miles@tarski:shapeless (master)% sbt -Dsbt.profile=2.12.x | |
[info] Loading global plugins from /home/miles/.sbt/0.13/plugins | |
[info] Loading project definition from /home/miles/projects/shapeless/project | |
[info] Set current project to root (in build file:/home/miles/projects/shapeless/) | |
> project coreJVM | |
[info] Set current project to core (in build file:/home/miles/projects/shapeless/) | |
> ++2.12.0-RC2 | |
[info] Setting version to 2.12.0-RC2 | |
[info] Reapplying settings... | |
[info] Set current project to core (in build file:/home/miles/projects/shapeless/) |
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
package demo | |
import scala.language.higherKinds | |
import scala.language.implicitConversions | |
trait Functor[F[_]] { | |
def map[A, B](fa: F[A])(f: A => B): F[B] | |
} | |
trait Monad[F[_]] extends Functor[F] { |
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.language.higherKinds | |
trait Functor[F[_]] { | |
def map[A, B](fa: F[A])(f: A => B): F[B] | |
} | |
trait Traverse[F[_]] { | |
implicit val F: Functor[F] | |
} |
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
tapply: (a -> b) -> a -> b | |
tapply ab a = ab a | |
foo: (tapply List Nat) --OK | |
foo = [1, 2, 3] | |
mkPair: a -> b -> (a, b) | |
mkPair a b = (a, b) | |
bar: (mkPair Nat String) -- Not OK |
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
// Compiled with ./build/pack/bin/scalac -J-Xss4M -J-Xmx4G test/files/pos/inductive-implicits.scala | |
// HList scalac scalac + | |
// Size inductive heuristics | |
// 50 6 4 | |
// 100 15 5 | |
// 150 36 6 | |
// 200 68 6 | |
// 250 114 7 | |
// 300 179 9 |
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
scala> def stuff(xs: ::[Int]): Int = xs.head | |
stuff: (xs: ::[Int])Int | |
scala> stuff(Nil) | |
<console>:13: error: type mismatch; | |
found : scala.collection.immutable.Nil.type | |
required: ::[Int] | |
stuff(Nil) | |
^ |
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
scala> def narrow[T <: Singleton](t: T): T {} = t | |
narrow: [T <: Singleton](t: T)T | |
scala> narrow(23) | |
res1: 23 = 23 | |
scala> var x = narrow(42) | |
x: 42 = 42 | |
scala> |
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
### Keybase proof | |
I hereby claim: | |
* I am milessabin on github. | |
* I am milessabin (https://keybase.io/milessabin) on keybase. | |
* I have a public key whose fingerprint is 87D4 DCA4 07A5 556C 0BAD D01F 420D 4BEE 9FA4 7A44 | |
To claim this, I am signing this object: |
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 { | |
def one[T <: 1](t: T): T = t | |
final val o = one(1) | |
o: 1 | |
def narrow[T <: Singleton](t: T): T {} = t | |
final val fn0 = narrow(23) | |
fn0: 23 | |
val n0 = narrow(23) |