Skip to content

Instantly share code, notes, and snippets.

View emilypi's full-sized avatar
🥝
hot girl summer

Emily Pillmore emilypi

🥝
hot girl summer
View GitHub Profile
@emilypi
emilypi / RB.hs
Created May 29, 2018 15:23
Functor Results
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
module RB where
import Data.Functor.Contravariant
newtype O f g e = Comp { deComp :: f (g e) }
newtype Square f a = Square { unSquare :: f (f a) }
@emilypi
emilypi / RB.hs
Created May 29, 2018 11:33
Interesting Bits from Rotten Bananas pt. I
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
module RB where
data F a
= Lam a (a -> a)
| Pi a (a -> a)
| App a a
@emilypi
emilypi / Nat.hs
Last active April 20, 2018 20:05
Nat Para + Cata
module Nat (
-- types
Algebra
, Coalgebra
, NatF
-- data
, Fix
, N
, Nat
-- methods
@emilypi
emilypi / DatatypesálaCarte.hs
Last active April 2, 2018 04:36
Datatypes a la Carte pt. I
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE RankNTypes #-}
module AlaCarte (
-- newtypes
Expr,
-- types
IntExpr,
AddExpr,
Algebra,
@emilypi
emilypi / dotfiles.el
Last active April 7, 2018 00:51
Emacs dotfiles
;; includes
(add-to-list 'load-path "~/.emacs.d/znc.el")
;; Initialize
(package-initialize)
;; global variables
(setq
inhibit-startup-screen t
create-lockfiles nil
@emilypi
emilypi / Foo.idr
Last active February 17, 2018 04:20
Creating a simple function in Idris for you to play with
module Foo
public export
data Foo = Try Int | Again Int
implementation Show Foo where
show (Try n) = "(Try " ++ (show n) ++ ")"
show (Again n) = "(Again " ++ (show n) ++ ")"
export
@emilypi
emilypi / FFree.scala
Created January 13, 2018 19:12
FFree
sealed abstract class FFree[F[_], A] {
def map[B](f: A => B): FFree[F, B] =
flatMap[B](a => FFree.pure[F, B](f(a)))
def flatMap[B](k: A => FFree[F, B]): FFree[F, B] =
this match {
case FFree.Pure(a) => k(a)
case FFree.Impure(ff, rs) => FFree.impure(ff, rs.:+(Kleisli.wrapKleisli(k)))
}
@emilypi
emilypi / FreeCodensity.hs
Created January 10, 2018 20:44
Codensity FreeLike instance
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
module Codensity where
newtype Codensity m a = Codensity { runCodensity :: forall b. (a -> m b) -> m b }
abs :: Monad m => (a -> m b) -> Codensity m a -> m b
abs k (Codensity c) = c k
trait CodensityModule {
type Codensity[M[_], A]
def abs[M[_], A](c: Codensity[M, A])(implicit M: Monad[M]): M[A]
def rep[M[_], A](ma: M[A])(implicit M: Monad[M]): Codensity[M, A]
}
private[data] object CodensityImpl extends CodensityModule with CodensityInstances {
@emilypi
emilypi / Mu.scala
Created December 15, 2017 20:52
Cows go Muuu
package cohomolo.gy.generalized
import scalaz.Prelude.{<~<, IsCovariant}
import scalaz.data.{As, Identity, ~>, ∀}
//final case class Mu[F[_]](unMu: Algebra[F, ?] ~> Identity)
trait MuModule {
type Mu[F[_]]