Skip to content

Instantly share code, notes, and snippets.

Avatar

Ionuț G. Stan igstan

View GitHub Profile
View visitors-1.scala
trait SACVisitor[R] {
def c1(a: Int): R
def c2(a: R, b: R): R
}
sealed trait SAC extends Product with Serializable {
def fold[R](visitor: SACVisitor[R]): R
}
object SAC {
View StateComposition.scala
import cats.implicits._
import cats.Monad
import cats.data.State
//
// Two capability/tagless final traits: Foo & Bar
//
trait Foo[F[_]] {
def foo: F[Unit]
}
View execution.log
$ ./to-csv.sed records.xml
111111H2,111AA2026
111111N1,111AA2026
111111Q1,111AA2026
111111U1,111AA2026
111111Z1,111AA2026
View BubbleUpObservable.scala
import cats.Eq
import monix.reactive.Observable
import monix.execution.Scheduler.Implicits.global
object Main {
implicit final class ObservableOps[A](private val self: Observable[A]) extends AnyVal {
def bubbleUpHot(a: A)(implicit Eq: Eq[A]): Observable[A] =
self.publishSelector { hot =>
val special = hot.find(_ === a)
val beforeSpecial = hot.takeWhile(_ =!= a)
View OptionalVisitor.scala
trait Optional[A] {
def visit[R](visitor: Optional.Visitor[A, R]): R
// Alias to show that visiting is similar to pattern matching.
def matching[R](visitor: Optional.Visitor[A, R]): R =
visit(visitor)
}
object Optional {
View ServicePrincipal.ts
import * as azure from "@pulumi/azure";
import * as azuread from "@pulumi/azuread";
import * as pulumi from "@pulumi/pulumi";
import * as random from "@pulumi/random";
export const app = new azuread.Application('pulumi', {
availableToOtherTenants: false,
homepage: "http://example.com",
identifierUris: ["http://example.com"],
oauth2AllowImplicitFlow: true,
View bucharestfp-61.md

Bucharest FP #61 — Implementing IMP in K and Haskell

Event Agenda

  • 18:45 — 19:00 Welcome
  • 19:00 — 20:00 Everett Hildenbrandt — Side-by-side implementation of an IMP language in K and Haskell
  • 20:00 — 21:00 Networking

Talk Abstract

View QuotedString.scala
final class QuotedString(private val sc: StringContext) extends AnyVal {
/**
* {{{
* scala> val msg = "foo"
* msg: String = foo
*
* scala> qs"$msg"
* res1: String = "foo"
*
* scala> qs"<$msg"
@igstan
igstan / RecordingApplicative.hs
Last active Aug 22, 2021
An Applicative that records the instructions of underlying computations.
View RecordingApplicative.hs
{-# LANGUAGE DeriveFunctor #-}
import Control.Applicative
import Control.Monad.Writer
import Control.Monad.Reader
import Control.Monad.Identity
import Data.Map (Map, (!))
import qualified Data.Map as Map
import Data.List (groupBy, intercalate, nub)
import Data.Function (on)
View gist:104442ea863fb90321475edb1eac251a
package com.example.http4splayground.services
import java.util.Date
import java.util.concurrent.TimeUnit
import cats._
import cats.data.StateT
import cats.effect.{ExitCode, IO, IOApp}
import cats.implicits._
import cats.mtl.MonadState