Skip to content

Instantly share code, notes, and snippets.

View err0r500's full-sized avatar

Matthieu Jacquot err0r500

View GitHub Profile
@err0r500
err0r500 / main.hs
Created August 31, 2018 12:27
Haskell monadic typeclass
module Main where
import Control.Monad.Identity
-- boostrap the conditions leading to 2 different implementations of the same business logic
main :: IO ()
main = do
-- use a monad instance as 1st parameter in order to choose the implementation
expectedCalledWithMaybeInstance <- putStrLn $ getFirstName Nothing "heyhey"
expectedCalledWithIOInstance <- putStrLn $ getFirstName (Identity 0) "hoho"
@err0r500
err0r500 / main.hs
Created September 4, 2018 13:30
monad stacking example
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
module Main where
import Control.Monad.Except
import Control.Monad.Reader
import Control.Monad.State
import Control.Monad.Writer
@err0r500
err0r500 / main.hs
Created September 4, 2018 19:18
monadic business logic
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
import Control.Monad.Identity
data User = User
{ name :: String
, firstName :: String
@err0r500
err0r500 / main.hs
Last active September 5, 2018 12:51
business logic
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
import Control.Monad.Identity
import Control.Monad.Trans.Either
import Control.Monad.Trans.Except
data User = User
@err0r500
err0r500 / codeKitchen3.tidal
Last active January 18, 2019 23:17
tidal patch made during Creative Code Paris - Code Kitchen #3 listen : https://soundcloud.com/err0r_500/creative-code-paris-code-kitchen-3
do
let mG = 1
let s1G = 0.8
let s2G = 0.6
let s3G = 0.8
let s1Striation = 50
let s3Striation = 250
let s1 = every 4 rev
$ every 2 (spread fast [2, 3, 1, 2] )
$ every 3 (# speed 4)
do
let s1 =
sometimes (degradeBy 0.9) $
sound "sn sn ~ ~ sn*3, ~ ~ sn*3/3 ~ ~"
let s2 =
rarely (jux (iter 4)) $
sometimes rev $
rarely (striate 3) $
rarely (striate 40) $
spread ($) [
type UnionFinder interface {
Union(p, r int)
Connected(p, r int) bool
}
// clean : Weighted Quick Union with Path Compression algorithm
type clean struct {
ids []int
weights []int
}
type UnionFinder interface {
Union(p, r int)
Connected(p, r int) bool
}
// wqupc : Weighted Quick Union with Path Compression algorithm
type wqupc struct {
ids []int
w []int
}
[global_config]
always_split_with_profile = True
borderless = True
focus = mouse
inactive_color_offset = 0.0
title_font = Fira Code 9
title_use_system_font = False
[keybindings]
close_term = <Super>w
go_down = <Super>j
.> run http.example.echo
ucm: can't hashComponents if bindings have free variables:
["User \"\\8461#0hoa6tis7604fo17o91lfjflsvd843uvm7sueu5rfqqn5nbneajoh9fldfbmmjnhh1h2690ktfflrbb96q9lksesuh3t5amcc1ph92g\"","User \"\\8461#ausqmo0vrtdm6lo1l2c0o6aord9i20hsap890ruk3s48mb8g6akn810inn23h46dffa0it6jhhit97un6645vocn3b9vfg93g2p8n40\"","User \"\\8461#bivcubo21g1dv6dvi6og2glj7up42tjmkm32kt8s60c5b91hmmhcvaegmkfs91im8sb8rpsducpdssjiv8t07en6dgs6rv7qj7odtb0\"","User \"\\8461#cqe9aa74fsjcg589r4rkiif3rm6o4trk8n06bg5d9rbhsaf1eiehmeufotfcsde4h88ldg7d21gcdi822925qlub4cr3bip7ssihrt8\"","User \"\\8461#do0af4msvjr540dam9fq3qv9b1t0kjg8g9ldokj1v6o15li140k381h6vrk9369fin8qv319oi38thsnensf970u7kl2hcacch67vm0\"","User \"\\8461#e95a9ev05jdao981r1qcb3cott58bonl77jm205j4uv8ctvdedn5rthicig5igb4veoqvgdoklhnfpsvlelvbm72gk53b232mgei1l0\"","User \"\\8461#gn13vdupub60p22r3lc5107bc3jq1vl9s0l93hq80naemb9e4f7bqdavfc7pr0uvug8on0qqcrk23cbo8pam08b2flffi8j98h5duq8\"","User \"\\8461#j1ejquc7so57gceg2fsnurckebs21napum8h7jbs58bmefncgvb8h654kcp6tdt31epf