Skip to content

Instantly share code, notes, and snippets.

View kaychaks's full-sized avatar
🦥

Kaushik Chakraborty kaychaks

🦥
View GitHub Profile
@channingwalton
channingwalton / TypeClass.scala
Created May 8, 2012 20:39
Typeclass in the presence of subtypes
import scala.xml.NodeSeq
object RenderExample {
object Model {
trait Toy
case class Bike extends Toy
case class Train extends Toy
@debasishg
debasishg / gist:6c13f3f57080a9655463
Last active July 31, 2018 01:37
links to papers / books on succinct data structures ..
From Theory to Practice: Plug and Play with Succinct Data Structures - Simon Gog, Timo Beller, Alistair Moffat & Matthias Petri (http://arxiv.org/pdf/1311.1249v1.pdf)
Succinct Data Structures for Retrieval and Approximate Membership - Martin Dietzfelbinger and Rasmus Pagh (http://www.itu.dk/people/pagh/papers/bloomier.pdf)
Lecture 17 in Erik Demaine's 6.851 (https://courses.csail.mit.edu/6.851/spring12/lectures/L17.html)
Succinct Data Sstructures by Edward Kmett (https://www.youtube.com/watch?v=uA0Z7_4J7u8)
Succinct Trees in Practice by Diego Arroyuelo, Rodrigo Ćanova, †Gonzalo Navaror Kunihiko Sadakane http://users.dcc.uchile.cl/~darroyue/papers/alenex2010.pdf
@puffnfresh
puffnfresh / Payments.hs
Created March 12, 2019 06:36 — forked from friedbrice/Payments.hs
Java6-compatible algebraic data types via Church-Scott Encoding
module Payments where
data Customer = Customer { name :: String, age :: Int } deriving (Eq, Ord, Show)
-- I know partial record fields is an anti-pattern, but who's counting?
data Payment
= Cash { customer :: Customer, amount :: Double }
| Credit { customer :: Customer, amount :: Double, cardNumber :: Int }
| Check { customer :: Customer, amount :: Double, routingNumber :: Int, accountNumber :: Int }
deriving (Eq, Ord, Show)
@Gabriella439
Gabriella439 / api-design.txt
Last active April 12, 2020 13:20
API design notes
* Importance of category theory
* Answers the question: "What is a *timeless* API?"
* What does "timeless" mean?
* Likely to still be relevant years from now
* Likely to be low maintenance (since unlikely to change)
* Less likely to be subject to controversy or discussion ("obvious")
* Examples:
* Everything Haskell's typeclassopedia (except maybe `Foldable`)
* Categories / Monoids
* `(.)` / `id`
@i-am-tom
i-am-tom / Trolling.hs
Created May 11, 2019 17:03
Ramda-style composition where the first function must receive all arguments.
{-# LAnguage FlexibleInstances #-}
{-# LANGuage FunctionalDependencies #-}
{-# LANGUAge GADTs #-}
{-# LANGUAGE UndecidableInstances #-}
module Trolling where
---------------------------------------------------------------------
-- VARIADIC COMPOSITION IN HASKELL (A LA RAMDA.JS).
--
-- In Haskell, we typeically think of the composition operator (or
@rahulmutt
rahulmutt / Main.hs
Last active October 1, 2020 04:44
Fast coproducts for Haskell & Eta
#!/usr/bin/env stack
{- stack
--resolver lts-6.27
--install-ghc
runghc
--package containers
-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
@non
non / laws.md
Last active February 20, 2022 00:26
I feel like conversations around laws and lawfulness in Scala are often not productive, due to a lack of rigor involved. I wanted to try to be as clear and specific as possible about my views of lawful (and unlawful) behavior, and what I consider a correct and rigorous way to think about laws (and their limits) in Scala.

Laws

A law is a group of two or more expressions which are required to be the same. The expressions will usually involve one or more typed holes ("inputs") which vary.

Some examples:

x.map(id) === x
@sevanspowell
sevanspowell / EmacsTooling.md
Last active July 6, 2022 01:11
A guide to setting up the Haskell tooling for Emacs in a Nix environment.

Running Emacs Haskell Tooling in a Nix environment

A guide to setting up the Haskell tooling for Emacs in a Nix environment.

Suggestions/Contact

mail@sevanspowell.net

Configuration

@suewonjp
suewonjp / .tmux.conf
Last active December 17, 2022 19:35
My .tmux.conf ( usable across multi-platforms including OS X | Linux | Cygwin )
set-option -g default-terminal "xterm-256color"
set-window-option -g xterm-keys on
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | cut -c 6-)"
setw -g mode-keys vi
unbind C-b
# remap prefix to Control + Space