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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": "autoscaling:Describe*", | |
"Effect": "Allow", | |
"Resource": "*" | |
}, | |
{ | |
"Action": "ec2:*", |
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
> [email protected] start /home/escala | |
> npm run server:dev | |
> [email protected] server:dev /home/escala | |
> cross-env NODE_ENV=development npm run webpack-dev-server -- --inline --progress --profile --watch | |
> [email protected] webpack-dev-server /home/escala | |
> cross-env BABEL_ENV=node ./node_modules/.bin/webpack-dev-server "--inline" "--progress" "--profile" "--watch" |
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
use futures::StreamExt; | |
use std::error::Error; | |
use tokio; | |
use tokio::macros::support::Pin; | |
use tokio::prelude::*; | |
use tokio::time::{Duration, Instant}; | |
pub fn main() -> Result<(), Box<dyn std::error::Error>> { | |
let mut multi_threaded_runtime = tokio::runtime::Builder::new() | |
.threaded_scheduler() |
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
type IOEither[A] = EitherT[IO, String, A] | |
type IOEitherOption[A] = OptionT[IOEither, A] |
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
val getJobStatus: Config => IO[Status] = ??? | |
def sendAlert(status: Status): Config => IO[Unit] = ??? | |
// ReaderT[F[_], E, A] is a type alias of Kleisli[F, E, A] so we can use the Kleisli constructor to wrap our functions | |
val getJobStatusR: ReaderT[IO, Config, Status] = Kleisli(getJobStatus) | |
def sendAlertR(status: Status): ReaderT[IO, Config, Unit] = Kleisli(sendEmail(status)) | |
val program: ReaderT[IO, Config, Unit] = for { | |
status <- getJobStatusR | |
_ <- sendAlertR(status, user) |
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 MonadReader[F[_], E] { | |
val monad: Monad[F] | |
def ask: F[E] | |
def reader[A](f: E => F[A]): F[A] | |
} |
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
def createMonadReader[E](value: E): IO[MonadReader[IO, E]] = { | |
for { | |
input <- Ref.of[IO, E](value) | |
} yield new MonadReader[IO, E] { | |
val monad: Monad[IO] = Monad[IO] | |
def ask: IO[E] = input.get | |
def reader[A](f: E => IO[A]): IO[A] = ask.flatMap(f) | |
} | |
} |
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
def program(R: MonadReader[IO, Config]): IO[Unit] = { | |
for { | |
status <- R.reader(getJobStatus) | |
_ <- R.reader(sendAlert(status)) | |
} yield () | |
} |
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
sealed trait Status | |
case object Healthy extends Status | |
case object Degraded extends Status | |
case object Unavailable extends Status | |
case class Env(serverUrl: String) | |
case class SystemState(value: Map[Env, Status]) | |
def getServerStatus[F[_]](): Env => F[Status] = ??? | |
def alertAdmin[F[_]](status: Status): Env => F[Unit] = ??? |
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
final class IndexedReaderWriterStateT[F[_], E, L, SA, SB, A](val runF: F[(E, SA) => F[(L, SB, A)]]) { | |
def map[B](f: A => B)(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, L, SA, SB, B] = { | |
transform { (l, s, a) => (l, s, f(a)) } | |
} | |
def transform[LL, SC, B](f: (L, SB, A) => (LL, SC, B)) | |
(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, LL, SA, SC, B] = { | |
IndexedReaderWriterStateT.applyF { | |
F.map(runF) { rwsfa => |
OlderNewer