Skip to content

Instantly share code, notes, and snippets.

View dgouyette's full-sized avatar
🏠
Working from home

GOUYETTE Damien dgouyette

🏠
Working from home
View GitHub Profile
@dgouyette
dgouyette / Grand_systeme.md
Last active September 23, 2025 09:17
Grand_systeme.md

Le Grand Système - Règles Phonétiques

Règles importantes

  1. Les voyelles (a, e, i, o, u, y) ne comptent pas et servent de séparation
  2. Les consonnes muettes ne se prononcent pas donc ne comptent pas
  3. Les consonnes doubles ne comptent que pour un seul chiffre
  4. H est toujours muet et ne compte pas
  5. W se prononce comme V (= 8) en français, comme OU (ne compte pas) en anglais
val t1Int : Option[Int] = Some(5)
val t2Int :Option[Int]= Some(6)
val t1String : Option[String] = Some("5")
val t2String :Option[String]= Some("6")
case class MyTuple2[T](a : Option[T], b : Option[T]){
def mapN(f : (T, T)=> T) :Option[T] = {
trait Functor[Box[_]] {
def map[In, Out](boxA: Box[In])(f: In => Out): Box[Out]
}
object Functor {
implicit val functorOption = new Functor[Option] {
override def map[In, Out](boxA: Option[In])(f: In => Out) = boxA.map(f)
}
implicit val functorList = new Functor[List] {
@dgouyette
dgouyette / PathOrRepath.scala
Last active May 18, 2017 12:37
PathOrRepath
import pivot.Rules
import jto.validation._
Rules.maxLength(2).validate("messageWithoutPath")//Invalid(List((/,List(ValidationError(List(error.maxLength),WrappedArray(2))))))
val nomEmptyWithPAth = Rules.notEmpty.repath(_ => Path \"newPath")
nomEmptyWithPAth.validate("")// Invalid(List((/newPath,List(ValidationError(List(error.required),WrappedArray())))))
import jto.validation._
import jto.validation.From
import jto.validation.xml.Rules._
import scala.xml.Node
val rule: Rule[Node, Option[String]] = From[Node] { __ => (__ \ "MyPath" ).read[Option[String]] }
case class Foo(
import jto.validation._
sealed trait Color
object Color {
case object Red extends Color
case object Orange extends Color
case object Green extends Color
val colorR : Rule[String, Color] = Rule.fromMapping {
case "Red" => Valid(Red)
case "Orange" => Valid(Orange)
case "Green" => Valid(Green)
import jto.validation.{Rule, VA}
import shapeless.Poly1
import shapeless._
import labelled.{FieldType, field}
object validator extends Poly1 {
implicit def list[H <: Validator[Int], T <: HList](implicit witness: Witness.Aux[H]) : Case.Aux[FieldType[H, String]::T, HList] = at(l => validator(l.head) :: HNil )
implicit def kvString[K <: Validator[String]](implicit witness: Witness.Aux[K]): Case.Aux[FieldType[K, String], VA[String]] = at(in => {
import jto.validation.{Rule, VA}
import shapeless.Witness
import shapeless.labelled.{FieldType, field}
import shapeless._
import scala.language.implicitConversions
trait Validator {
def rules: Rule[String, String]
import jto.validation.{Rule, VA}
import shapeless.Witness
import shapeless.labelled.{FieldType, field}
trait Validator {
this: String =>
val rules: Rule[String, String]
def validate: VA[String] = rules.validate(this)
}
package stripes
import cats.free.Free
import cats.~>
import freek._