Skip to content

Instantly share code, notes, and snippets.

View kaychaks's full-sized avatar
🦥

Kaushik Chakraborty kaychaks

🦥
View GitHub Profile
@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 #-}
@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
@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`
@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)
@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
@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