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 sbt._ | |
import Keys._ | |
import Build.data | |
object build extends Build { | |
lazy val runAll = TaskKey[Unit]("run-all") | |
lazy val standardSettings = Seq( | |
runAllIn(Compile) | |
) |
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 akka.actor | |
import collection.mutable | |
import akka.actor.FSM.{ CurrentState, Transition, UnsubscribeTransitionCallBack, SubscribeTransitionCallBack } | |
import akka.routing.{ Deafen, Listen } | |
case object PreRestart | |
case object PostRestart | |
trait ParentNotification { thisActor: Actor ⇒ |
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
class PatMatCrash { | |
def foo[T](pattern: PartialFunction[T, Unit]) = ??? | |
// CRASHES | |
foo { | |
case "foo" => () | |
} | |
// does NOT crash | |
foo[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
[22:34] < mightybyte> But data-lens isn't up to date with it. | |
[22:34] < edwardk> ghci> :t sumOf folded | |
[22:34] < edwardk> sumOf folded :: (Num c, Data.Foldable.Foldable f) => f c -> c | |
[22:35] < mightybyte> Hah! I was wondering how long you'd be able to resist. | |
[22:35] < edwardk> but we can use sumOf with any Lens, Traversal or Fold, etc. | |
[22:35] < edwardk> for instance: sumOf (traverse.traverse):: (Num c, Traversable t1, Traversable t) => t (t1 c) -> c | |
[22:35] < edwardk> sumOf (traverse._2), ec. | |
[22:36] < edwardk> toListOf (traverse.traverseLeft) :: Traversable t => t (Either c c1) -> [c] | |
[22:36] < edwardk> basically traverse is a valid Traversal, but there are lots of others | |
[22:38] < edwardk> so multilenses become 'Traversals' and you can do things like: productOf (traverseValueAt 4), etc. |
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 sbtcomplete | |
import sbt._ | |
import complete.JLineCompletion | |
import Keys._ | |
object SbtComplete { | |
private val CompletionsCommand = "completions" | |
private val CompletionsBrief = ("<arg>", "The string to complete.") |
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 scalaz.lens | |
import scalaz.Functor | |
case class Store[C, D, B](f: D => B, c: C) | |
object Store extends StoreInstances | |
trait StoreInstances { | |
implicit def storeFunctor[C, D]: Functor[({type l[b]=Store[C, D, b]})#l] = new Functor[({type l[b]=Store[C, D, b]})#l] { | |
def map[A, B](fa: Store[C, D, A])(f: A => B): Store[C, D, B] = { |
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
> tests/test:print-ascii-graph | |
[info] org.scalaz:scalaz-tests_2.9.2:7.0-SNAPSHOT | |
[info] +-org.scala-lang:scala-library:2.9.2 | |
[info] +-org.scala-tools.testing:scalacheck_2.9.1:1.9 | |
[info] | +-org.scala-tools.testing:test-interface:0.5 | |
[info] | | |
[info] +-org.scalaz:scalaz-concurrent_2.9.2:7.0-SNAPSHOT | |
[info] | +-org.scala-lang:scala-library:2.9.2 | |
[info] | +-org.scalaz:scalaz-core_2.9.2:7.0-SNAPSHOT | |
[info] | +-org.scala-lang:scala-library:2.9.2 |
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
// original, broken version | |
def many[A](a: F[A]): F[List[A]] = { | |
lazy val y: Free.Trampoline[F[List[A]]] = z map (plus(_, point(Nil))) | |
lazy val z: Free.Trampoline[F[List[A]]] = y map (map2(a, _)(_ :: _)) | |
y.run | |
} | |
// trying to make sense of trampoline |
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
scala> import scalaz._ | |
import scalaz._ | |
scala> import Scalaz._ | |
import Scalaz._ | |
scala> Option(17) match { | |
| case opt @ Some(_) if opt /== Option(42) => | |
| } | |
<console>:48: error: type mismatch; |
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
trait PolyParse[F[_]] { | |
def F: Functor[F] | |
def APP: Applicative[F] | |
def ALT: Alternative[F] | |
def C: Commitment[F] | |
def M: MonadFail[F] | |
} | |
def oneOf[FA](fas: List[FA])(implicit U: Unapply[PolyParse, FA]): U.M[U.A] = fas match { | |
case Nil => U.TC.M.fail[U.A]("failed to parse any of the possible choices".toList) |