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
@typeclass trait NonEmptyTraverseUnordered[F[_]] { | |
def nonEmptyTraverseUnordered[G[_]: CommutativeApply, A, B](sa: F[A])(f: A => G[B]): G[F[B]] | |
def nonEmptySequenceUnordered[G[_]: CommutativeApply, A](fga: F[G[A]]): G[F[A]] = | |
nonEmptyTraverseUnordered(fga)(identity) | |
} | |
@typeclass trait NonEmptyCommutativeParallel[F[_], M[_]] { | |
def commutativeApply: CommutativeApply[F] | |
def commutativeFlatMap: CommutativeFlatMap[M] |
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 cats.free | |
import cats.free.Free.{FlatMapped, Pure, Suspend} | |
import cats.{Applicative, Monad, Parallel, ~>} | |
import cats.implicits._ | |
class FreeParallel[S[_], A](val value: Free[FreeApplicative[S, ?], A]) extends AnyVal | |
object FreeParallel { | |
def apply[S[_], A](fp: Free[FreeApplicative[S, ? ], A]): FreeParallel[S, A] = new FreeParallel(fp) |
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 cats._ | |
import cats.implicits._ | |
trait Alg[M[_]] { | |
def doSomething(s: String): M[Unit] | |
} | |
object AlgVect extends Alg[Vector] { | |
def doSomething(s: String): Vector[Unit] = Vector(println(s)) | |
} |
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 Stack[E, A] = EitherT[Future, NonEmptyList[E], A] | |
def longRunningComputation(person: Person): Future[Either[NonEmptyList[Error], Result]] = ??? | |
val people: List[Person] = ??? | |
val result: Stack[Error], List[Result]] = | |
people.parTraverse(longRunningComputation _ andThen EitherT.apply) |
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 IO[+T](run: => T) { | |
def map[R](f: T => R): IO[R] = { | |
IO(f(run)) | |
} | |
def flatMap[R](f: T => IO[R]): IO[R] = { | |
IO(f(run).unsafeRun()) | |
} | |
def unsafeRun(): T = run |
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
module Main where | |
import OutWatch | |
import Builder ((<==)) | |
import Control.Monad.Eff (Eff) | |
import Prelude (Unit, map, (#), (+)) | |
import RxJS.Observable (interval, startWith) | |
main :: Eff () Unit | |
main = let |
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 Container f1 f2 f3 = | |
{ children :: f1 String | |
, friends :: f2 Int | |
, colleagues :: f3 Number | |
} | |
data SomeType f1 f2 f3 a e = Container (Container f1 f2 f3) | |
| AnotherType a | |
| SomeEffect (Eff e Unit) |
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 Html exposing (beginnerProgram, div, button, text, ul, li, input, Html) | |
import Html.Events exposing (onClick, onInput) | |
import Array exposing (Array, toList, fromList, push, filter) | |
main = | |
beginnerProgram { model = initialState, view = view, update = update } | |
type alias Model = { list: Array String, currentText: String } |
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
val nameStream = createInputHandler() | |
val component = div( | |
label(className := "label", "Name:"), | |
input(inputType := "text", input --> nameStream), | |
hr(), | |
h1("Hello ", child <-- nameStream) | |
) | |
render(document.getElementById("app"), component) |
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
//So now after letting IntelliJ convert our file to Kotlin we get this: | |
//... but there's an error | |
class ExampleActivity : AppCompatActivity() { | |
private var foo: String? = "Bar" | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) |