Skip to content

Instantly share code, notes, and snippets.

Ionuț G. Stan igstan

Block or report user

Report or block igstan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
]
View free.scala
import scala.concurrent.Future
import cats.~>
import cats.data.ReaderT
import cats.free.Free
object FreeMonads {
sealed trait Op[A]
object Op {
final case class Get[T](name: String) extends Op[T]
View factorial.eve
# Factorial in Eve
## Base Case
```eve
search
r = [#factorial n: 0]
bind
r.return := 1
```
## Recursive Case
View patterns.swift
indirect enum Type: CustomStringConvertible {
case Int
case Fun(Type, Type)
var isFun: Bool {
switch self {
case .Fun: return true
case _: return false
}
}
View set.sml
signature TAGGED_ORD =
sig
type t
type a
val wrap : int -> t
val compare : t * t -> order
val asRecord : { wrap : a -> t, compare : t * t -> order }
end
View mixin.sml
functor Member(Flag : sig type t end) =
struct
(* Define types and values common to both MemberA and MemberB. *)
end
(*
* MemberA and MemberB differ only in the declaration of Flag, the rest of
* the types and values are the same and come from the Member functor.
*)
structure MemberA =
You can’t perform that action at this time.