Type | Functor | Apply | Applicative | Bind | Monad | MonoidK | MonadError | Cobind | Comonad |
---|---|---|---|---|---|---|---|---|---|
Id[A] | β | β | β | β | β | β | β | β | β |
Option[A] | β | β | β | β | β | β | β | β | β |
Const[K, A] | β | β (K:Monoid ) |
β | β | β | β | β | ? | ? |
Either[E, A] | β | β | β | β | β | β | β | β | β |
List[A] | β | β | β | β | β | β | β | β | β |
NonEmptyList[A] | β |
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 fpmax | |
import scala.util.Try | |
import scala.io.StdIn.readLine | |
object App0 { | |
def main: Unit = { | |
println("What is your name?") | |
val name = readLine() |
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 arrow.Kind | |
import arrow.core.Option | |
import arrow.core.left | |
import arrow.core.right | |
import arrow.effects.typeclasses.Async | |
import arrow.typeclasses.ApplicativeError | |
data class UserId(val value: String) | |
data class User(val userId: UserId) | |
data class Task(val value: 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
package kategory | |
import io.kotlintest.matchers.* | |
import io.kotlintest.specs.FreeSpec | |
import kategory.Problem.* | |
import kotlin.reflect.KClass | |
/*** Kategory.io documentation as runnable code ***/ | |
class DataTypeExamples : FreeSpec() { init { |
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
using UnityEngine; | |
using System.Collections.Generic; | |
// Written by Steve Streeting 2017 | |
// License: CC0 Public Domain http://creativecommons.org/publicdomain/zero/1.0/ | |
/// <summary> | |
/// Component which will flicker a linked light while active by changing its | |
/// intensity between the min and max values given. The flickering can be | |
/// sharp or smoothed depending on the value of the smoothing parameter. |
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 kotterknife | |
import android.app.Activity | |
import android.app.Dialog | |
import android.app.DialogFragment | |
import android.app.Fragment | |
import android.arch.lifecycle.Lifecycle | |
import android.arch.lifecycle.LifecycleObserver | |
import android.arch.lifecycle.LifecycleOwner | |
import android.arch.lifecycle.OnLifecycleEvent |
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
#!/bin/bash | |
# Prompts for device to use from adb devices -l first; inserts -s parameter. | |
# No sanitizing, error checking or warranties! | |
# Use like | |
# $choose_device adb shell | |
DEVICES=`adb devices -l | sed 1d` | |
PS3="Choose device or Ctrl+C to quit: " |
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 Observable<SearchResult> search(@NotNull EditText searchView) { | |
return RxTextView.textChanges(searchView) // In production, share this text view observable, don't create a new one each time | |
.map(CharSequence::toString) | |
.debounce(500, TimeUnit.MILLISECONDS) // Avoid getting spammed with key stroke changes | |
.filter(s -> s.length() > 1) // Only interested in queries of length greater than 1 | |
.observeOn(workerScheduler) // Next set of operations will be network so switch to an IO Scheduler (or worker) | |
.switchMap(query -> searchService.query(query) // Take the latest observable from upstream and unsubscribe from any previous subscriptions | |
.onErrorResumeNext(Observable.empty()); // <-- This fixes the problem since the error is not seen by the upstream observable | |
} |
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 com.squareup.moshi.JsonAdapter; | |
import com.squareup.moshi.JsonDataException; | |
import com.squareup.moshi.JsonReader; | |
import com.squareup.moshi.JsonWriter; | |
import com.squareup.moshi.Moshi; | |
import com.squareup.moshi.Types; | |
import java.io.IOException; | |
import java.lang.annotation.Annotation; | |
import java.lang.reflect.Type; | |
import java.util.LinkedHashMap; |
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
fun BriteDatabase.createQuery(query: SqlDelightStatement) = createQuery(query.tables, query.statement, *query.args) | |
inline fun <T: SqlDelightCompiledStatement> BriteDatabase.bindAndExecute(compiledStatement: T, bind: T.() -> Unit): Long { | |
synchronized(compiledStatement) { | |
compiledStatement.bind() | |
return when (compiledStatement) { | |
is SqlDelightCompiledStatement.Insert -> { | |
executeInsert(compiledStatement.table, compiledStatement.program) | |
} | |
is SqlDelightCompiledStatement.Update -> { |