I hereby claim:
- I am suhailshergill on github.
- I am shergill (https://keybase.io/shergill) on keybase.
- I have a public key whose fingerprint is 623E 49E5 27D5 5D95 AA69 CE52 8956 DBE3 13DA 7380
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| import scala.language.higherKinds | |
| trait Monad[M[_]] { | |
| implicit def `Monad ~> Functor`[M[_]: Monad]: Functor[M] = new Functor[M]{} | |
| } | |
| trait Functor[F[_]] { | |
| } | |
| object Functor { |
| -- [[file:~/Dropbox/Public/papers/pl/haskell/free/free-applicative-functors_capriotti-kaposi.org::*%5B%5Bhttp://hackage.haskell.org/package/free-4.7.1/docs/Control-Monad-Free.html%5D%5BFree%20monad%5D%5D][su/haskell/free/FreeAL/modulo]] | |
| {-# LANGUAGE NoImplicitPrelude #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# OPTIONS -fno-warn-orphans #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE UndecidableInstances #-} |
| (defun su/monkeypatch/nil-fun (&rest args)) | |
| (defvar su/monkeypatch/nil-var nil) | |
| (defun su/monkeypatch/mangle-name (symbol prefix) | |
| (concat "su/monkeypatches/" prefix (symbol-name symbol)) | |
| ) | |
| (defun su/monkeypatch/copy-values (source-symbol dest-symbol) | |
| "This function copies values from source to dest. It does not keep any | |
| backups. I f you want that you want to use 'su/monkeypatch' instead" | |
| (ignore-errors |
| object TTFI { | |
| object Initial { | |
| // {{{ OOP | |
| object OOP { | |
| // extending language is easy, adding more functions is hard since it | |
| // involves having to modify each case class | |
| trait Exp[A] { | |
| def eval: A |
| -- The illustration of the Boehm-Berarducci encoding | |
| -- This file is the baseline: using ordinary algebraic | |
| -- data type and operations of constructions, deconstructions | |
| -- and transformation. | |
| -- We use the running example of the Exp data type from | |
| -- tagless-final lectures | |
| module BB_ADT where |
| import java.io._ | |
| @SerialVersionUID(15L) | |
| class Animal(name: String, age: Int) extends Serializable { | |
| override def toString = s"Animal($name, $age)" | |
| } | |
| case class Person(name: String) | |
| // or fork := true in sbt |
| #! /usr/bin/env python | |
| """ Email Me. | |
| Usage: | |
| emailme <message> | |
| emailme [-s] <message> | |
| emailme [-s] <subject> <message> | |
| emailme <toaddr> <subject> <message> | |
| emailme <toaddr> <fromaddr> <subject> <message> | |
| emailme -h | --help |
| from itertools import imap | |
| def foo(x): return iter(x) # function which returns an iter | |
| bar = ["bar", "baz"] | |
| list(foo("bar")) | |
| #[Out]# ['b', 'a', 'r'] | |
| baz = iter(bar) # iterator of inputs | |
| qu = (item for sublist in imap(foo, baz) for item in sublist) | |
| list(qu) # demonstration of chaining things together |
| import org.apache.spark.SparkContext | |
| import org.apache.spark.rdd.RDD | |
| /** | |
| * I am trying to narrow down on an Exception thrown by Spark when using "Factories". | |
| * The factories have parameters that are used in the classes' functions. | |
| * | |
| * To run this code: copy-paste this whole content in a Spark-Shell. Execute Test.theMain(sc) | |
| * | |
| */ |