Skip to content

Instantly share code, notes, and snippets.

Avatar

Ionuț G. Stan igstan

View GitHub Profile
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 Oct 7, 2019
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
@igstan
igstan / kind-polymorphism.scala
Last active May 16, 2018 — forked from szeiger/gist:3a2e7e65b641bac9764a9c02de233ab9
Kind-polymorphic Any and Nothing
View kind-polymorphism.scala
scala> import scala.language.higherKinds
import scala.language.higherKinds
scala> def f[C[_], E]: List[C[E]] = Nil
f: [C[_], E]=> List[C[E]]
scala> f[List, Int]
res0: List[List[Int]] = List()
scala> f[Any, Int]
View IntervalMapSuite.scala
// libraryDependencies += "com.rklaehn" %% "intervalset" % "0.2.0"
import java.time.Instant
import scala.collection.immutable.SortedSet
import com.rklaehn.interval.IntervalMap.{ Value, FromBool => IntervalMap }
import org.scalatest.FunSuite
import spire.algebra.Order
import spire.implicits.StringOrder
import spire.math.Interval
import spire.optional.genericEq.generic
@igstan
igstan / hogof.py
Last active Apr 2, 2018
Higher-Order Gang of Four
View hogof.py
# hogof — Higher-Order Gang of Four
# data Fix s a = In{out :: s a (Fix s a)}
def flatten(xss):
return [
x
for xs in xss
for x in xs
]
You can’t perform that action at this time.