Skip to content

Instantly share code, notes, and snippets.

View madidier's full-sized avatar

Maxime DIDIER madidier

  • Strasbourg, France
View GitHub Profile
@madidier
madidier / Tabulata.hs
Last active October 22, 2016 11:55
A general DSL for consuming structured tabular data (i.e. wide CSVs, XLSXs...)
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module Tabulata
( -- * Types
Fields
, Range
@madidier
madidier / Freegram.hs
Created November 16, 2016 23:32
Johachim Breitner's Applicative showcase, free applicative version
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
module Freegram where
import Bnf
import Parser
import Control.Applicative.Free.Final
import Data.Maybe (catMaybes)
@madidier
madidier / Either-hof.agda
Last active July 6, 2023 12:05
Sum type encoding and catamorphism of "Either" in various languages and approaches
-- I haven't been able to actually run the program (broken archlinux packages), but it typechecks
open import Data.String
open import Function
open import IO.Primitive
Either : Set → Set → Set₁
Either l r = {a : Set} → (l → a) → (r → a) → a
Left : { l r : Set } → l → Either l r
@madidier
madidier / Lambda.pro
Last active March 18, 2018 17:54
Lambda calculus simplifier and interpreter in SWI prolog
/*
* AST definition
*/
:- op(100, fx , (:)).
:- op(200, yfx, ($)).
:- op(300, xfy, (->)).
isName(N) :- N =.. [_].
{-# LANGUAGE BangPatterns #-}
module Iota
( Expr(..)
, run
) where
import Prelude hiding (succ)
import Control.Monad (void)
import Data.Char (chr, ord)
@madidier
madidier / F.java
Last active July 5, 2017 19:45
Interpreters for Iota/IotaM
import java.io.*;
import java.util.function.*;
@FunctionalInterface
public interface F {
F $(F α);
default Object μ() {
return null;
}
@madidier
madidier / Typeclass.fs
Last active July 16, 2017 11:15
Oh, god ! I did it !
module Typeclass
type __<'f, 'a> = interface end
// __<fμ, 'a> -> f<'a>
let inline ω (x: __<'f, 'a>) = (^f: (static member ω : __<'f, 'a> -> 'b) x)
// f<'a> -> __<fμ, 'a>
let inline μ (x: 'a) = (x :> __<'f, 'b>)
// ==UserScript==
// @name Pesky MSDN translations !
// @namespace http://madidier.github.com/
// @version 0.2
// @description Disable translations on MSDN and other MS documentation sites.
// @author Maxime A. Didier
// @match https://*.microsoft.com/fr-fr/*
// @grant none
// ==/UserScript==
@madidier
madidier / bbn.user.js
Created July 24, 2023 20:29
BlueBird Necromancer
// ==UserScript==
// @name BlueBird Necromancer
// @namespace https://twitter.com/madidier_
// @version 0.1
// @description Bring back the blue bird from the dead!
// @author @madidier_
// @match https://twitter.com/*
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJkSURBVHgB7VZBbtpQEH3zIW0WVYuXVaH4Bs0NSk4AOUFhEarskhMknIDsqkKlcIT0BNAT1D1B3ZJK3dmVuirwp/MhVmzAxiagKBJv9+ePZ97M/JkxsMMODwzChlD84FWQp3MxeCDHAhiumB+MJrr1+8Ryw3p/9+H4DctfIPCq49Xlw8Kv99YlMuB19885gy/i7llziwGfFFWJyR02XzSCuwiBUse7BlFVaz5LS8KQVkRXaXRJsqImfDjKSZBNyzEyFWFKVJ4KFbWLElUao6KbSk8i9TXgTPaorxTskPwOxa7/9baGt4zg8oQbNyfWYJlRU0/KUx9ZwNwYNq1ecFRzl18QpW0bB0Ks//KjV1uwlbuLJA3GxEdh5wb5yGEPl3qMd2xecYQHKnlFlVLX95kxYCFKGg5IlU2a0uLpCM68LEJA+sJ/Dm6Jy3aMjQIRakRUm+UuvfOp/X34iQSejeFo0Hdx4optG5uFH/R+GHNvANcm3VtwLs+Lvy2TRwhIOnrYHhysIuDKcCDwGbYAjglOzQt+HssElF6dvoNNOZeuCSbfSgIGMjILMo4/ExZf7TqghNLmlwm1gpSC2tmaLAZMvWGz0Iu7XpqBm2NrQNN5cD+Y5
@madidier
madidier / unindent.js
Created August 16, 2023 22:42
JavaScript unindent tagged template literal
const unindent = (strings, ...values) => {
// Quick and not so dirty unindented template strings.
// Handles tabs very roughly if they are present.
// The very first line is always left as is if not entirely whitespace,
// and removed otherwise.
const matchLine = line => {
const {groups} =
/^(?<line>(?<indent>[\t ]*)(?<nonws>[^\n]*)\n?)(?<tail>.*)$/s.exec(line);
return {