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 java.util.concurrent.atomic.AtomicReference | |
import java.util.concurrent.CountDownLatch | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext | |
import ExecutionContext.Implicits.global | |
object TxMapTest { | |
/* | |
* Example Usage | |
* We want to show two threads working with the same data source having both of their effects succeed |
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
date | cases | county | |
---|---|---|---|
02-01-2020 | 1 | Orange | |
02-02-2020 | 0 | Orange | |
02-03-2020 | 0 | Orange | |
02-04-2020 | 0 | Orange | |
02-05-2020 | 0 | Orange | |
02-06-2020 | 0 | Orange | |
02-07-2020 | 0 | Orange | |
02-08-2020 | 0 | Orange | |
02-09-2020 | 0 | Orange |
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
//Reader Monad and its extension class to give it SelectMany(bind/flatMap) capabilities for use in LINQ queries | |
public static class ReaderMonadExt | |
{ | |
public static ReaderMonad<T, C> SelectMany<T, A, B, C>(this ReaderMonad<T, A> rm, Func<A, ReaderMonad<T, B>> bindf, Func<A, B, C> select) | |
{ | |
return new ReaderMonad<T, C>(t => | |
{ | |
var a = rm.Run(t); | |
return select(a, bindf(a).Run(t)); | |
}); |
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 Event { | |
@PartitionKey(0) public UUID accountId | |
@PartitionKey(1)public String yearMonthDay; | |
@ClusteringKey public UUID eventId; | |
//other data... | |
} | |
public static void sampleUsage() { | |
//we want to ONLY query data from three years ago for a set of accounts, so we will generate that somehow. | |
//Also note that one token will likely generate many Events... |
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 Test { | |
import scalaz.\/ | |
import scala.concurrent.{ExecutionContext, Await, Future} | |
import scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scalaz.syntax.std.option._ | |
def flipOption[A](l: List[Option[A]]): Option[List[A]] = | |
l.foldLeft(List[A]().some) | |
((accumulator: Option[List[A]], optiona: Option[A]) => accumulator.flatMap((la: List[A]) => optiona.map((a: A) => a :: la))) |
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 scalaz._ | |
import Scalaz._ | |
import IndexedStateT._ | |
type ParserM[S, A] = EitherT[({ type l[a] = StateT[Trampoline, S, a]})#l, String, A] | |
def getVerbose[S]: ParserM[S, S] = { | |
//https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/main/scala/scalaz/MonadState.scala | |
val monadState = stateTMonadState[S, Trampoline] | |
val state: StateT[Trampoline, S, S] = monadState.get |
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
As a past and future speaker of LambdaConf, I wanted to share my thoughts on the Curtis Yarvin controversy. I do not agree | |
with excluding attendees nor speakers because of their beliefs or writings. However, it has become clear to me that Curtis Yarvin | |
has been and continues to be disingenuous when it comes to his claim of separating himself from his 'Moldbug' persona. This, combined | |
with his large sphere of influence in a repgunant political movement leads me to believe having Curtis at LambdaConf will detract from | |
the overall goal of spreading functional programming as well as reaching under represented groups. I do not support Lambda Conf's | |
decision to allow Curtis Yarvin to speak in 2016. I coninue to support LambdaConf's overall mission of inclusion, am happy to see they | |
continue to offer divirsity scholarships, and plan on speaking in 2016 despite Curtis Yarvin's attendance. |
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 taskSeparation[F[_], A](fa: List[F[A]])(implicit M: Catchable[F], N: Nondeterminism[F]): F[(List[Throwable], List[A])] = | |
N.gatherUnordered(fa.map(f => M.attempt(f))).map(_.separate) |
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 System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace XSharpx { | |
public struct Writer<A, B> | |
{ | |
public readonly A a; | |
public readonly B b; | |
public readonly Semigroup<A> semigroup; |
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 liftT[G[_[_], _], M[_]: Monad, A](a: M[A])(implicit ML: MonadLiftT[G, F], M: Monad[M]): G[M, A] = ML.liftT[M, A](M.map(a)(aa => point(aa))) |
NewerOlder