Last active
August 29, 2015 14:13
-
-
Save xuwei-k/dc09e1714ff9af91d202 to your computer and use it in GitHub Desktop.
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
trait Applicative[F[_]]{ | |
def point[A](a: => A): F[A] | |
def ap[A, B](fa: => F[A])(ff: => F[A => B]): F[B] | |
def map[A, B](fa: F[A])(f: A => B): F[B] = | |
ap(fa)(point(f)) | |
def apply2[A, B, C](fa: => F[A], fb: => F[B])(f: (A, B) => C): F[C] = | |
ap(fb)(map(fa)(f.curried)) | |
} |
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
scalaVersion := "2.11.5" |
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
[info] Loading global plugins from /Users/user/.sbt/0.13/plugins | |
[info] Compiling 1 Scala source to /Users/user/.sbt/0.13/plugins/target/scala-2.10/sbt-0.13/classes... | |
[info] Loading project definition from /Users/user/freeap/project | |
[info] Set current project to freeap (in build file:/Users/user/freeap/) | |
[info] Compiling 3 Scala sources to /Users/user/freeap/target/scala-2.11/classes... | |
exception when typing FreeAp.freeInstance().apply2({ | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}, { | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
})/class scala.reflect.internal.Trees$Apply | |
not enough arguments for method apply2: (fa: Function0, fb: Function0, f: Function2)Object. | |
Unspecified value parameter f. in file /Users/user/freeap/Main.scala | |
[error] | |
[error] unrecoverable error | |
[error] while compiling: /Users/user/freeap/Main.scala | |
[error] during phase: globalPhase=erasure, enteringPhase=posterasure | |
[error] library version: version 2.11.5 | |
[error] compiler version: version 2.11.5 | |
[error] reconstructed args: -classpath /Users/user/freeap/target/scala-2.11/classes -bootclasspath /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/classes:/Users/user/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.5.jar | |
[error] | |
[error] last tree to typer: TypeTree(class FreeAp) | |
[error] tree position: line 37 of /Users/user/freeap/FreeAp.scala | |
[error] tree tpe: FreeAp | |
[error] symbol: (sealed abstract) class FreeAp | |
[error] symbol definition: sealed abstract class FreeAp extends Object (a ClassSymbol) | |
[error] symbol package: <empty> | |
[error] symbol owners: class FreeAp | |
[error] call site: method main in object Main in package <empty> | |
[error] | |
[error] == Source file context for tree position == | |
[error] | |
[error] 34 type I = A | |
[error] 35 lazy val v = value | |
[error] 36 lazy val k = function | |
[error] 37 } | |
[error] 38 } | |
[error] 39 | |
[error] 40 | |
exception when typing { | |
FreeAp.freeInstance().apply2({ | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}, { | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}); | |
() | |
} | |
exception when typing { | |
val x: FreeAp = FreeAp.lift({ | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): Option = scala.Option.apply(1); | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}); | |
{ | |
FreeAp.freeInstance().apply2({ | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}, { | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}); | |
() | |
} | |
} | |
exception when typing def main(args: Array[String]): Unit = { | |
val x: FreeAp = FreeAp.lift({ | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): Option = scala.Option.apply(1); | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}); | |
{ | |
FreeAp.freeInstance().apply2({ | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}, { | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}); | |
() | |
} | |
} | |
exception when typing object Main extends Object { | |
def <init>(): Main.type = { | |
Main.super.<init>(); | |
() | |
}; | |
def main(args: Array[String]): Unit = { | |
val x: FreeAp = FreeAp.lift({ | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): Option = scala.Option.apply(1); | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}); | |
{ | |
FreeAp.freeInstance().apply2({ | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}, { | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}); | |
() | |
} | |
} | |
} | |
exception when typing package <empty> { | |
object Main extends Object { | |
def <init>(): Main.type = { | |
Main.super.<init>(); | |
() | |
}; | |
def main(args: Array[String]): Unit = { | |
val x: FreeAp = FreeAp.lift({ | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): Option = scala.Option.apply(1); | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}); | |
{ | |
FreeAp.freeInstance().apply2({ | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}, { | |
@SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0 with Serializable { | |
def <init>(): <$anon: Function0> = { | |
$anonfun.super.<init>(); | |
() | |
}; | |
final def apply(): FreeAp = x; | |
final <bridge> <artifact> def apply(): Object = $anonfun.this.apply() | |
}; | |
(new <$anon: Function0>(): Function0) | |
}); | |
() | |
} | |
} | |
} | |
} | |
scala.reflect.internal.FatalError: | |
unrecoverable error | |
while compiling: /Users/user/freeap/Main.scala | |
during phase: globalPhase=erasure, enteringPhase=posterasure | |
library version: version 2.11.5 | |
compiler version: version 2.11.5 | |
reconstructed args: -classpath /Users/user/freeap/target/scala-2.11/classes -bootclasspath /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/classes:/Users/user/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.5.jar | |
last tree to typer: TypeTree(class FreeAp) | |
tree position: line 37 of /Users/user/freeap/FreeAp.scala | |
tree tpe: FreeAp | |
symbol: (sealed abstract) class FreeAp | |
symbol definition: sealed abstract class FreeAp extends Object (a ClassSymbol) | |
symbol package: <empty> | |
symbol owners: class FreeAp | |
call site: method main in object Main in package <empty> | |
== Source file context for tree position == | |
34 type I = A | |
35 lazy val v = value | |
36 lazy val k = function | |
37 } | |
38 } | |
39 | |
40 | |
at scala.reflect.internal.Reporting$class.abort(Reporting.scala:59) | |
at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:16) | |
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:703) | |
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5373) | |
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5400) | |
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5347) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5351) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5429) | |
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3028) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3132) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3132) | |
at scala.collection.immutable.List.loop$1(List.scala:173) | |
at scala.collection.immutable.List.mapConserve(List.scala:189) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3132) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedBlock(Typers.scala:2363) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedOutsidePatternMode$1$1.apply(Typers.scala:5295) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedOutsidePatternMode$1$1.apply(Typers.scala:5295) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedOutsidePatternMode$1(Typers.scala:5294) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5330) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5337) | |
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:696) | |
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5373) | |
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5400) | |
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5347) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5351) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedBlock(Typers.scala:2364) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedOutsidePatternMode$1$1.apply(Typers.scala:5295) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedOutsidePatternMode$1$1.apply(Typers.scala:5295) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedOutsidePatternMode$1(Typers.scala:5294) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5330) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5337) | |
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:696) | |
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5373) | |
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5400) | |
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5347) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5351) | |
at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:5582) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:2190) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5285) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5336) | |
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:696) | |
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5373) | |
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5400) | |
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5347) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5351) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5429) | |
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3028) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3132) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3132) | |
at scala.collection.immutable.List.loop$1(List.scala:173) | |
at scala.collection.immutable.List.mapConserve(List.scala:189) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3132) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1903) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1744) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5286) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5336) | |
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:696) | |
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5373) | |
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5400) | |
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5347) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5351) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5429) | |
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3028) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3132) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3132) | |
at scala.collection.immutable.List.loop$1(List.scala:173) | |
at scala.collection.immutable.List.mapConserve(List.scala:189) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3132) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:4989) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5289) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5336) | |
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:696) | |
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5373) | |
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5400) | |
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5347) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5351) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5425) | |
at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anonfun$transform$2.apply(Erasure.scala:1166) | |
at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anonfun$transform$2.apply(Erasure.scala:1162) | |
at scala.reflect.internal.SymbolTable.enteringPhase(SymbolTable.scala:235) | |
at scala.reflect.internal.SymbolTable.exitingPhase(SymbolTable.scala:256) | |
at scala.tools.nsc.transform.Erasure$ErasureTransformer.transform(Erasure.scala:1162) | |
at scala.tools.nsc.transform.Erasure$ErasureTransformer.transform(Erasure.scala:743) | |
at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:147) | |
at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:30) | |
at scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply$mcV$sp(Global.scala:441) | |
at scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:432) | |
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:441) | |
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:399) | |
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:399) | |
at scala.collection.Iterator$class.foreach(Iterator.scala:750) | |
at scala.collection.AbstractIterator.foreach(Iterator.scala:1202) | |
at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:399) | |
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1500) | |
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1487) | |
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1482) | |
at scala.tools.nsc.Global$Run.compile(Global.scala:1580) | |
at xsbt.CachedCompiler0.run(CompilerInterface.scala:116) | |
at xsbt.CachedCompiler0.run(CompilerInterface.scala:95) | |
at xsbt.CompilerInterface.run(CompilerInterface.scala:26) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:483) | |
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:101) | |
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:47) | |
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41) | |
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:97) | |
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:97) | |
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:97) | |
at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:162) | |
at sbt.compiler.AggressiveCompile$$anonfun$3.compileScala$1(AggressiveCompile.scala:96) | |
at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:139) | |
at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:86) | |
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:38) | |
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:36) | |
at sbt.inc.IncrementalCommon.cycle(IncrementalCommon.scala:31) | |
at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:39) | |
at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:38) | |
at sbt.inc.Incremental$.manageClassfiles(Incremental.scala:66) | |
at sbt.inc.Incremental$.compile(Incremental.scala:38) | |
at sbt.inc.IncrementalCompile$.apply(Compile.scala:26) | |
at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:153) | |
at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:70) | |
at sbt.compiler.AggressiveCompile.apply(AggressiveCompile.scala:45) | |
at sbt.Compiler$.apply(Compiler.scala:74) | |
at sbt.Compiler$.apply(Compiler.scala:65) | |
at sbt.Defaults$.sbt$Defaults$$compileTaskImpl(Defaults.scala:789) | |
at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:781) | |
at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:781) | |
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47) | |
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40) | |
at sbt.std.Transform$$anon$4.work(System.scala:63) | |
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226) | |
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226) | |
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17) | |
at sbt.Execute.work(Execute.scala:235) | |
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226) | |
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226) | |
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159) | |
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28) | |
at java.util.concurrent.FutureTask.run(FutureTask.java:266) | |
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) | |
at java.util.concurrent.FutureTask.run(FutureTask.java:266) | |
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) | |
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) | |
at java.lang.Thread.run(Thread.java:745) | |
[error] (compile:compile) scala.reflect.internal.FatalError: | |
[error] unrecoverable error | |
[error] while compiling: /Users/user/freeap/Main.scala | |
[error] during phase: globalPhase=erasure, enteringPhase=posterasure | |
[error] library version: version 2.11.5 | |
[error] compiler version: version 2.11.5 | |
[error] reconstructed args: -classpath /Users/user/freeap/target/scala-2.11/classes -bootclasspath /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/classes:/Users/user/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.5.jar | |
[error] | |
[error] last tree to typer: TypeTree(class FreeAp) | |
[error] tree position: line 37 of /Users/user/freeap/FreeAp.scala | |
[error] tree tpe: FreeAp | |
[error] symbol: (sealed abstract) class FreeAp | |
[error] symbol definition: sealed abstract class FreeAp extends Object (a ClassSymbol) | |
[error] symbol package: <empty> | |
[error] symbol owners: class FreeAp | |
[error] call site: method main in object Main in package <empty> | |
[error] | |
[error] == Source file context for tree position == | |
[error] | |
[error] 34 type I = A | |
[error] 35 lazy val v = value | |
[error] 36 lazy val k = function | |
[error] 37 } | |
[error] 38 } | |
[error] 39 | |
[error] 40 | |
[error] Total time: 3 s, completed 2015/01/17 19:40:36 |
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
sealed abstract class FreeAp[F[_],A] { | |
import FreeAp._ | |
def ap[B](f: FreeAp[F, A => B]): FreeAp[F,B] = f match { | |
case Pure(g) => map(g) | |
case x@Ap() => FreeAp(x.v, ap(x.k.map(g => (a:A) => (b:x.I) => g(b)(a)))) | |
} | |
def map[B](f: A => B): FreeAp[F,B] = this match { | |
case Pure(a) => Pure(f(a)) | |
case x@Ap() => FreeAp(x.v, x.k.map(f compose _)) | |
} | |
} | |
object FreeAp { | |
implicit def freeInstance[F[_]]: Applicative[({type λ[α] = FreeAp[F,α]})#λ] = | |
new Applicative[({type λ[α] = FreeAp[F,α]})#λ] { | |
def point[A](a: => A) = FreeAp.point(a) | |
def ap[A,B](fa: => FreeAp[F,A])(ff: => FreeAp[F, A => B]) = fa ap ff | |
} | |
def point[F[_],A](a: A): FreeAp[F,A] = Pure(a) | |
def lift[F[_],A](x: => F[A]): FreeAp[F, A] = FreeAp(x, Pure((a: A) => a)) | |
private final case class Pure[F[_],A](a: A) extends FreeAp[F,A] | |
private abstract case class Ap[F[_],A]() extends FreeAp[F,A] { | |
type I | |
def v: F[I] | |
def k: FreeAp[F, I => A] | |
} | |
def apply[F[_],A,B](value: => F[A], function: => FreeAp[F, A => B]): FreeAp[F,B] = | |
new Ap[F,B] { | |
type I = A | |
lazy val v = value | |
lazy val k = function | |
} | |
} |
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 Main { | |
def main(args: Array[String]): Unit = { | |
val x: FreeAp[Option, Int] = FreeAp.lift(Option(1)) | |
FreeAp.freeInstance[Option].apply2(x, x) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://issues.scala-lang.org/browse/SI-9093