Skip to content

Instantly share code, notes, and snippets.

Phil Freeman paf31

Block or report user

Report or block paf31

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@paf31
paf31 / ToPursTyConPoly.hs
Last active May 14, 2019
ToPursTyConPoly
View ToPursTyConPoly.hs
{-# language TypeInType #-}
-- | Types which have PureScript equivalents
class ToPursTyCon a where
toPursTyCon :: Tagged a PursTypeConstructor
-- | The default instance uses 'G.Generic' and pattern matches on the
-- type's representation to create a PureScript type.
default toPursTyCon :: (G.Generic a, GenericToPursTyCon (G.Rep a)) => Tagged a PursTypeConstructor
toPursTyCon = retag $ genericToPursTyConWith @(G.Rep a) defaultPursTypeOptions
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
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
paf31 / FreeAp.md
Last active Feb 22, 2019
FreeAp f is a Comonad
View FreeAp.md

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
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
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
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
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
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
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
You can’t perform that action at this time.