This file contains 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
/* | |
This code was made to investigate if it is possible | |
to use a batch API as if it were a single item one. | |
More precisely, I have this batch API: | |
final case class Request(id: Int) | |
final case class Response(id: Int) |
This file contains 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
/* | |
This piece of commented code aims to clarify some | |
misconceptions between several advanced concepts | |
in pure functional programming/category theory: | |
free monads, finally tagless approach, algebraic | |
effects. | |
These concepts are actually very close. They rely | |
on similar concepts and even represent the "same" | |
object (up to isomorphism!) from the theoretical |
This file contains 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 Test { | |
/** Simple definition of Heterogeneous Lists | |
*/ | |
sealed abstract class HList { | |
def :::[H](head: H): H ::: this.type = Test.:::(head, this) | |
} | |
/** The empty list |
This file contains 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 proof that the type {{{A}}} is of | |
* the form {{{F[elem]}}} for some type | |
* {{{elem}}}. | |
*/ | |
sealed abstract class IsA[F[_], A] { | |
type elem | |
def fold[G[_]](p: G[F[elem]]): G[A] | |
@inline implicit final def to: A =:= F[elem] = { | |
type G[X] = X =:= F[elem] |
This file contains 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 scala.collection.immutable.TreeSet | |
import scala.language.higherKinds | |
/***************************************** | |
* A Category | |
*/ | |
trait Cat { cat => | |
type obj[A] | |
type arr[A, B] |
This file contains 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 scala.language.higherKinds | |
import scala.language.implicitConversions | |
import scala.util.Random | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits._ | |
/** A simple trait telling how to save in DB */ | |
sealed trait DBMode { | |
type Op[_] | |
def saveInDB[A](a: A): Op[A] |
This file contains 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
(** We aim to show that the classic Reader monad is equivalent | |
to an ADT (more precisely a GADT (Generalized Algebraic Data Types). | |
*) | |
Section ForStephane. | |
(** The reader config type (what's read) | |
* | |
* trait Config | |
*) |
This file contains 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
Informations de l'ordinateur : | |
Fabricant : Unknown | |
Modèle : Unknown | |
Type : Ordinateur de bureau | |
Aucun écran tactile détecté | |
Processeur : | |
Fabricant du CPU : GenuineIntel | |
Marque du processeur : Intel(R) Core(TM) i5-4670K CPU @ 3.40GHz | |
Famille du processeur : 0x6 |
This file contains 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 scala.language.higherKinds | |
object Toto { | |
trait Monad[M[_]] { | |
def pure[A](value: A): M[A] | |
def flatMap[A,B](ma: M[A], f: A => M[B]): M[B] | |
final def map[A,B](ma: M[A], f: A => B): M[B] = | |
flatMap(ma, f `andThen` pure) |
This file contains 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 scala.language.implicitConversions | |
object CHK { | |
/* Quand on sait convertir un type | |
A dans B et réciproquement | |
*/ | |
trait Conversion[A,B] { self => | |
def to: A => B | |
def from: B => A |