Skip to content

Instantly share code, notes, and snippets.

View crdueck's full-sized avatar

Chris Dueck crdueck

View GitHub Profile
@KingoftheHomeless
KingoftheHomeless / Como.hs
Last active November 15, 2018 20:42
The dual to Mo. A new comonad-to-monad transformer.
{-# LANGUAGE RankNTypes #-}
module Como where
import Control.Comonad
import Control.Monad.Identity
import Control.Monad.Trans
-- The dual to Mo.
-- Simplified (still isomorphic): ComoT { runComoT' :: forall r. (a -> m (w r)) -> m r }
-- ComoT w Identity ~ forall r. (a -> w r) -> r
-- Unlike (Mo m Identity), (ComoT w Identity) is interesting in its own right. In fact, it gives rise to some really strange monads. See below.
@KingoftheHomeless
KingoftheHomeless / Mo.hs
Last active November 15, 2018 20:42
The monad-to-comonad transformer
{-# LANGUAGE RankNTypes, GADTs #-}
module Mo where
import Control.Comonad
import Control.Comonad.Trans.Class
import Control.Monad
{-
The monad-to-comonad transformer.
Originally, Mo was defined as the simpler (and isomorphic):
data Mo m w a where
@Icelandjack
Icelandjack / Constraints.org
Last active April 2, 2024 20:22
Type Classes and Constraints

Reddit discussion.

Disclaimer 1: Type classes are great but they are not the right tool for every job. Enjoy some balance and balance to your balance.

Disclaimer 2: I should tidy this up but probably won’t.

Disclaimer 3: Yeah called it, better to be realistic.

Type classes are a language of their own, this is an attempt to document features and give a name to them.

@phadej
phadej / poly-nfdata.hs
Last active November 6, 2017 22:24
Example how is possible to write polykinded type-classes in GHC-8.0. It's not that bad or messy, but I'm not sure it's practical either.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
anonymous
anonymous / prompt_jemhuntr_setup
Created January 29, 2016 11:20
#
# A ZSH theme inspired by paradox and agnoster themes,
# supercharged with FontAwesome icons.
#
# This theme requires a patched Powerline font. You will also need to
# have FontAwesome set as default fallback font.
#
# Authors:
# Jerome Indefenzo <jeromeindefenzo@gmail.com>
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module DynBounded where
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@debasishg
debasishg / gist:8172796
Last active May 10, 2024 13:37
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&amp;rep=rep1&amp;t
@jboner
jboner / latency.txt
Last active June 27, 2024 14:47
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD