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
package eo | |
import cats.{Applicative, Bifunctor, Functor, Traverse} | |
import cats.arrow._ | |
import cats.implicits._ | |
trait Accessor[F[_, _]] { | |
def get[A]: [X] => F[X, A] => 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
package kobo | |
package assist | |
import scalacache.{Cache, Mode} | |
import fs2.{INothing, Pipe, Stream} | |
import fs2.concurrent._ | |
import cats.syntax.all._ | |
import cats.data.{EitherT, OptionT} |
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
#include <tl/expected.hpp> | |
#include <iostream> | |
#include <stdexcept> | |
#include <functional> | |
#include <variant> | |
// Logic in modern civilization | |
template<typename A, typename B> | |
using And = std::tuple<A, B>; |
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
import cats.effect.{IO, Timer} | |
import fs2.{Pull, Stream} | |
import org.http4s._ | |
import org.http4s.ServerSentEvent.EventId | |
import org.http4s.client.Client | |
import org.http4s.headers.{`Cache-Control`, Accept} | |
import scala.concurrent.duration._ | |
import SseClient._ | |
final class SseClient private ( |
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
{-# LANGUAGE OverloadedStrings #-} | |
module Example where | |
import Language.Marlowe | |
main :: IO () | |
main = print . pretty $ contract | |
{- Define a contract, Close is the simplest contract which just ends the contract straight away |
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
{-# LANGUAGE OverloadedStrings #-} | |
module Example where | |
import Language.Marlowe | |
main :: IO () | |
main = print . pretty $ contract | |
{- Define a contract, Close is the simplest contract which just ends the contract straight away |
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
object ModelXValidation { | |
def validateMotor(motor: Motor): Boolean = | |
motor.engine.fold(validateElecticEngine, validateCombustionEngine) | |
def validateElectricEngine(engine: ElectricEngine): Boolean = engine match { | |
case eh:HybridElectricEngine => false | |
case ElectricEngine(coils) => expectedCoils.contains(coils) | |
} | |
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
//A type A with Cardinality |A| = 5 | |
class ElectricEngine(core: MotorCoils) | |
case class HybridElectricEngine(volume: EngineVolume, fuel: Petrol.type) extends ElectricEngine(`1800Coils`) | |
//A type B with Cardinality |B| = 8 | |
case class CombustionEngine(volume: EngineVolume, fuel: FuelType, mod: Modification) |
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
/* It is common for the system to have more complex structures that house transactions, and these complex structures are what the system is dealing with | |
It could be balance sheets as defined earlier, but lets pretend there are other structures used for Fraud detection as well... | |
They are optionally there along with some arbitray metadata, and we need to run a verifier across the transactions inside these structures | |
It would seem like a lot of very specific code is needed to get all this done; but in reality we already have all the combinators we need: | |
*/ | |
def systemVerifier[S, Metadata](traversal: Traversal[S, Transaction], verifier: Pipe[IO, Transaction, Transaction]): Pipe[IO, (Option[S], Metadata), (Option[S], Metadata)] = | |
_.flatMap( | |
_1[(Option[S], Metadata), Option[S]] |
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
checkAll("balanceSheetTimes", TraversalTests(sheetTimes)) |
NewerOlder