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
class MoreMonadErrorOps[F[_], A](val fa: F[A]) extends AnyVal { | |
def liftError[G[_], C, D, E](nt: F ~> G)(raiseErr: C => G[E])(implicit G: MonadError[G, E], ev: A <~< Validation[C, D]): G[D] = | |
for { | |
a <- nt(fa) | |
validation = ev(a) | |
result <- validation.fold(raiseErr(_).flatMap(G.raiseError[D]), G.pure(_)) | |
} yield result |
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
def index(id: UUIDFor[File]): F[ValidationNel[StoreTreeError, List[DatabaseFile]]] = { | |
for { | |
maybeDbFile <- mToF(songDb.getDirectory(id)) | |
dbFile <- maybeDbFile.getOrElseF(F.raiseError[Directory](IndexTargetNotFoundInDatabase(id))) | |
maybeFileSystemTree <-nToF(fileTree(apiKeyToPath(dbFile.apiKey.value), None)) | |
fileSystemTree <- maybeFileSystemTree.getOrElseF(F.raiseError[FileTree](IndexTargetNotFoundInFileSystem(dbFile.apiKey.value))) | |
storedTree <- mToF(storeTree(fileSystemTree, None)) | |
} yield storedTree |
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 scalaz.effect | |
import java.util.concurrent.TimeUnit | |
import org.openjdk.jmh.annotations._ | |
import scala.concurrent.Await | |
import IOBenchmarks._ | |
@State(Scope.Thread) | |
@BenchmarkMode(Array(Mode.Throughput)) |
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
public class wot.DoIt { | |
public scala.collection.immutable.List<scala.Option<java.lang.Object>> foo(scala.collection.immutable.List<scala.Tuple2<java.lang.Object, scala.Option<java.lang.Object>>>); | |
Code: | |
0: aload_1 | |
1: invokedynamic #39, 0 // InvokeDynamic #0:apply:()Lscala/Function1; | |
6: getstatic #45 // Field scala/collection/immutable/List$.MODULE$:Lscala/collection/immutable/List$; | |
9: invokevirtual #49 // Method scala/collection/immutable/List$.canBuildFrom:()Lscala/collection/generic/CanBuildFrom; | |
12: invokevirtual #55 // Method scala/collection/immutable/List.map:(Lscala/Function1;Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object; | |
15: checkcast #51 // class scala/collection/immutable/List | |
18: areturn |
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
public final class wot.DoIt$$anonfun$foo$1$$anonfun$apply$1 extends scala.runtime.AbstractFunction1$mcII$sp implements scala.Serializable { | |
public static final long serialVersionUID; | |
public final int apply(int); | |
Code: | |
0: aload_0 | |
1: iload_1 | |
2: invokevirtual #20 // Method apply$mcII$sp:(I)I | |
5: ireturn |
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> val x: In = 10 | |
x: ScalaScript.In = 10 with properties Map() | |
scala> x.foo = "bar" | |
x.foo: Any = bar | |
scala> x | |
res4: ScalaScript.In = 10 with properties Map(foo -> bar with properties Map()) |
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.reflect.ClassTag | |
import scala.reflect.runtime.universe._ | |
import scala.language.dynamics | |
import scala.language.implicitConversions | |
import scala.reflect.api.{Mirror => SRMirror, TypeCreator, Universe} | |
import scala.Predef.{implicitly, locally, any2stringadd => _} | |
class ScalaScripter(val a: Any) extends Dynamic { | |
import ScalaScript.{enable => toScalaScript, disable => unScalaScript} |
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 trait Pipeline[A, B, C] { | |
def compose[D, E, F](that: Pipeline[D, E, F]): Compose[A, B, C, D, E] = Compose(this, that) | |
} | |
case class Compose[A, B, C, D, E](p1: Pipeline[A, B, C], p2: Pipeline[C, D, E]) extends Pipeline[A, (B, D), E] | |
case class Run[A, B, C](f: A => B => C) extends Pipeline[A, B, C] | |
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
type F1 = (A1, P1) => A2 | |
type F2 = (A2, P2) => A3 | |
type F3 = (A3, P3) => A4 | |
def foo(a1: A1): P1 => P2 => P3 => A4 = p1: P1 => p2: P2 => p3: P3 => F3(F2(F1(a1, p1), p2), p3) |
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
(=<<) f (OptionalT fMaybeA) = | |
OptionalT ( | |
fMaybeA >>= \o -> | |
case o of | |
Full x -> runOptionalT (f x) | |
Empty -> pure Empty) |