Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE StandaloneDeriving, FlexibleContexts, UndecidableInstances #-}
-- Laungh ghci with -fobject-code to make the Fix/Tree trick work (thanks edwardk).
-- courtesy of hpc on #haskell
import Unsafe.Coerce
import Control.Monad.ST
toInteger :: Int -> Integer
isJust :: Maybe a -> Bool
null :: [a] -> Bool
@michaelt
michaelt / RedBlackTree.hs
Created May 11, 2012 15:01 — forked from rampion/RedBlackTree.hs
red-black trees in haskell, using GADTs and Zippers (and DataKinds)
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DataKinds#-}
{-# LANGUAGE KindSignatures#-}
module RedBlackTree where
data Nat = Zero | Succ Nat deriving (Eq, Ord, Show)
type One = Succ Zero
@HeinrichApfelmus
HeinrichApfelmus / GameLoop.hs
Created October 2, 2012 16:49
Game loop in reactive-banana
{------------------------------------------------------------------------------
reactive-banana
Implementation of an "industry strength" game loop with fixed time step
and variable fps.
See also http://gafferongames.com/game-physics/fix-your-timestep/
-------------------------------------------------------------------------------}
{-# LANGUAGE NoMonomorphismRestriction #-}
module Main where
@imeckler
imeckler / gist:3885281
Created October 13, 2012 16:39
Pithy finite state machine in haskell
import Control.Monad
import Data.Maybe
import Prelude hiding (any, elem)
import Data.Foldable
type State = String
type Map a b = [(a, b)]
-- In Map State (Map Char (m State)), the monad m determines the kind of FSM that is being run.
-- If m = [] (or Set), these functions work as a NFA. If m = Maybe, we essentially have a DFA.
@arvearve
arvearve / gist:4158578
Created November 28, 2012 02:01
Mathematics: What do grad students in math do all day?

Mathematics: What do grad students in math do all day?

by Yasha Berchenko-Kogan

A lot of math grad school is reading books and papers and trying to understand what's going on. The difficulty is that reading math is not like reading a mystery thriller, and it's not even like reading a history book or a New York Times article.

The main issue is that, by the time you get to the frontiers of math, the words to describe the concepts don't really exist yet. Communicating these ideas is a bit like trying to explain a vacuum cleaner to someone who has never seen one, except you're only allowed to use words that are four letters long or shorter.

What can you say?

@ekmett
ekmett / ekmett_conf.log
Created April 1, 2013 04:30
#haskell-lens log from ekmett_conf
[00:24] fumieval (~fumieval@124x39x126x66.ap124.ftth.ucom.ne.jp) joined the channel.
[00:25] nushio3 (7c277e42@gateway/web/freenode/ip.124.39.126.66) joined the channel.
[00:25] nushio3: hi there!
[00:26] edwardk: hello, hello!
[00:27] hiratara (~hiratara@h223020.dynamic.ppp.asahi-net.or.jp) joined the channel.
[00:27] fumieval: hi
[00:28] carter: hello everyone! Wait, is this the presentation room now?
[00:30] edwardk: Yep
[00:30] carter: enjoy!
[00:30] tanakh_ (~tanakh@124x39x126x66.ap124.ftth.ucom.ne.jp) joined the channel.
@sjoerdvisscher
sjoerdvisscher / updatemonad.hs
Created May 8, 2013 09:21
The update monad which generalizes the reader, writer and state monad from http://homepages.inf.ed.ac.uk/s1225336/talks/types13.pdf
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses #-}
import Data.Monoid
import Data.Monoid.Action
import Data.Monoid.MList (SM(..))
import Control.Monad.Trans.Class
newtype UpdateT p s m a = UpdateT { runUpdateT :: s -> m (p, a) }
@pascalpoitras
pascalpoitras / config.md
Last active July 5, 2024 02:22
My WeeChat configuration

WeeChat Screenshot

Mouse


enable


module Printf
%default total
data Format = FInt Format -- %d
| FString Format -- %s
| FOther Char Format -- [a-zA-Z0-9]
| FEnd --
format : List Char -> Format
@sjoerdvisscher
sjoerdvisscher / adjointFoldPlain.hs
Last active July 26, 2023 13:04
Adjoint folds, using regular Category from base (but custom Functor)
-- http://www.cs.ox.ac.uk/ralf.hinze/SSGIP10/AdjointFolds.pdf
-- http://www.cs.ox.ac.uk/ralf.hinze/publications/SCP-78-11.pdf
-- https://www.cs.ox.ac.uk/people/nicolas.wu/papers/URS.pdf
-- https://arxiv.org/pdf/2202.13633.pdf
{-# LANGUAGE
MultiParamTypeClasses
, FunctionalDependencies
, GADTs
, PolyKinds