Skip to content

Instantly share code, notes, and snippets.

View bruno-cadorette's full-sized avatar

Bruno Cadorette bruno-cadorette

  • Sherbrooke
View GitHub Profile
@bruno-cadorette
bruno-cadorette / Maybe.cs
Created April 27, 2016 09:37
Haskell like maybe in C#. Contains functor, applicative functor and monad implementation. Do not use this in real code, C# 6.0 have the ?. operator that is nearly the same thing
using System;
namespace MaybeCSharp
{
interface IMaybe<T>
{
IMaybe<U> Bind<U>(Func<T, IMaybe<U>> f);
IMaybe<U> Map<U>(Func<T, U> f);
IMaybe<U> Ap<U>(IMaybe<Func<T, U>> f);
}
@bruno-cadorette
bruno-cadorette / index.js
Created August 15, 2017 03:03
Download a facebook conversation!
/*
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
### Keybase proof
I hereby claim:
* I am bruno-cadorette on github.
* I am brunocadorette (https://keybase.io/brunocadorette) on keybase.
* I have a public key ASDpLETUCCZ5yGWHBeGCTPt9d-RKxIOW9NeZIYe1nvICNgo
To claim this, I am signing this object:
@bruno-cadorette
bruno-cadorette / gist:5ea827c8b0677a6e63adbf60688e1ca8
Last active November 9, 2018 04:51
binary tree insertion using paramorphism
{-#LANGUAGE TypeFamilies, DeriveFunctor #-}
import Data.Functor.Foldable
data Tree a = Leaf | Node a (Tree a) (Tree a) deriving (Show)
data TreeF a b = LeafF | NodeF a b b deriving (Functor, Show)
type instance Base (Tree a) = TreeF a
instance Recursive (Tree a) where
project Leaf = LeafF
@bruno-cadorette
bruno-cadorette / removelast.coq
Created January 10, 2020 22:40
remove last algorithm equivalence proof
Require Import Coq.Lists.List.
Import Coq.Lists.List.ListNotations
Fixpoint my_remove_last {A : Type} (l : list A) : list A:=
match l with
| [] => []
| x :: [] => []
| x :: xs => x :: (my_remove_last xs)
end.
import Control.Applicative
import qualified Data.Map as Map
import Debug.Trace
import Data.Foldable
import Data.Maybe
import Data.Ord
import Data.List
import Data.List.NonEmpty (nonEmpty)
minTransitions ::