Skip to content

Instantly share code, notes, and snippets.

View hejfelix's full-sized avatar

Felix Bjært Hargreaves hejfelix

View GitHub Profile
class Foo[F[_]] {
}
@hejfelix
hejfelix / AccountService.scala
Created November 4, 2020 13:00
Context functions in Scala 3 with tests
import cats.Applicative
import cats.data.Kleisli
/**
* This highly modular service
* allows the call-site to pick and choose
* between the different functions while still
* sharing code for e.g. configuration/context.
*
* The opaque types `Name` and `AccountNumber` guarantee
module Lwp exposing (..)
import Binary exposing (fromIntegers, toDecimal)
import Bitwise exposing (and)
type alias Byte =
Int
type SystemType
module Advertising = {
type byte = int;
type systemType =
| LEGO_WeDo_2_0
| LEGO_Duplo
| LEGO_System_1
| LEGO_System_2
| UNKNOWN(byte);
package com.lambdaminute.wishr.slick.effect
import cats.effect.{Effect, IO}
import slick.dbio.DBIO
class DBIOEffectInstances {
val dbioEffect = new Effect[DBIO[_]] {
override def runAsync[A](fa: DBIO[_][A])(cb: (Either[Throwable, A]) => IO[Unit]) = ???
override def async[A](k: ((Either[Throwable, A]) => Unit) => Unit) = ???
def mySideEffect(i:Int ):Boolean = {
try {
//do something with i
if (scala.util.Random.nextBoolean) {
throw new Exception("Ooops")
}
} catch {
case _: Throwable => return false
}
return true