Skip to content

Instantly share code, notes, and snippets.

Phil Freeman paf31

View GitHub Profile
View which.purs
module Main where
import Prelude
import Data.Exists (Exists, mkExists, runExists)
import Unsafe.Coerce (unsafeCoerce)
-- Leibniz equality:
-- Two things are equal if they are substitutable in all contexts.
type Leib a b = forall f. f a -> f b
paf31 / Main.purs
Last active Feb 2, 2018
Try Behaviors
View Main.purs
module Main where
import Prelude
import Color (white)
import Color.Scheme.MaterialDesign (blueGrey)
import Control.Monad.Eff (Eff)
import Control.MonadZero (guard)
import Data.Array (sortBy, (..))
import Data.Foldable (foldMap)
paf31 /
Last active Feb 22, 2019
FreeAp f is a Comonad

FreeAp f is a Comonad

While thinking about comonads as spaces and Day convolution, I realized an interesting thing. The free applicative functor generated by a comonad f is also a comonad.

The free applicative can be defined in a few different ways, but I like to define it like this:

data FreeApplicative f a = Pure a | Free (Day f (FreeApplicative f) a)
paf31 / gist:e3feef9eb85c7ce9ce0a5e0db7441059
Last active Dec 10, 2016
PureScript projects needing ownership
View gist:e3feef9eb85c7ce9ce0a5e0db7441059
## Current owners
- Typechecker (Phil)
- Modules (Gary)
- Corefn optimization and codegen (Gary)
- Core libraries (Gary)
- IDE integration (Christoph)
- Pursuit (Harry)
- PSCi (Phil)
- Docs repo (Harry)
paf31 / traverse.purs
Created Nov 24, 2015
Profunctor-based Traversable
View traverse.purs
module Main where
import Prelude
import Data.Maybe
import Data.Either
import Data.Tuple
import Data.List
import Data.Profunctor
paf31 / Main.hs
Last active Sep 5, 2018
A simple type checker with Rank N types
View Main.hs
module Main where
import Data.Maybe (fromMaybe)
import Control.Applicative
import Control.Arrow (first)
import Control.Monad (ap)
import Debug.Trace
paf31 / ListT.purs
Created Aug 27, 2015
Stack-safe ListT in PureScript using FreeT
View ListT.purs
module Control.Monad.List.Trans where
import Prelude
import Data.List
import Data.Either
import Control.Apply
import Control.Bind
import Control.Monad.Eff
paf31 / .psci
Last active Dec 15, 2016
Minimal .psci file for 0.7
View .psci
:f bower_components/purescript-prelude/src/Prelude.js
:m bower_components/purescript-prelude/src/Prelude.purs
:f bower_components/purescript-eff/src/Control/Monad/Eff.js
:m bower_components/purescript-eff/src/Control/Monad/Eff.purs
:f bower_components/purescript-console/src/Control/Monad/Eff/Console.js
:m bower_components/purescript-console/src/Control/Monad/Eff/Console.purs
:f bower_components/purescript-eff/src/Control/Monad/Eff/Unsafe.js
:m bower_components/purescript-eff/src/Control/Monad/Eff/Unsafe.purs
import Prelude
import Control.Monad.Eff.Console
paf31 / W.lhs
Last active Feb 18, 2019
Algorithm W
View W.lhs
## Principal type-schemes for functional programs
**Luis Damas and Robin Milner, POPL '82**
> module W where
> import Data.List
> import Data.Maybe
> import Data.Function
paf31 / Tree.hs
Created Jun 4, 2015
Exhaustivity checking by tree coloring
View Tree.hs
module Tree where
data Binder = Wildcard | Zero | Succ Binder deriving (Show)
data Tree = Covered | Uncovered | Branch Tree Tree
color :: Tree -> Binder -> Tree
color _ Wildcard = Covered
color Covered _ = Covered
color Uncovered Zero = Branch Covered Uncovered
You can’t perform that action at this time.