Skip to content

Instantly share code, notes, and snippets.

View sellout's full-sized avatar
🍌
semper φ

Greg Pfeil sellout

🍌
semper φ
View GitHub Profile
inThisBuild(Seq(
scalaOrganization := "org.typelevel",
scalaVersion := "2.12.4-bin-typelevel-4",
scalacOptions := Seq(
"-Ykind-polymorphism",
"-Yno-imports"),
libraryDependencies := Seq(
"org.typelevel" %% "cats-core" % "1.3.0" % "compile, test")))
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.8")
-- === The Abstract ===
-- | A wrapper for `Applicative`-only semantics for types that also have a
-- `Monad`.
newtype Par m a = Par { unPar :: m a }
-- | A wrapper for `Monad` semantics for types that have a distinct
-- `Applicative`.
newtype Seq m a = Seq { unSeq :: m a }
module Data.Exofunctor
import Data.Morphisms
%access public export
%default total
-- replace Control.Category with this
interface Category (cat : k -> k -> Type) where
id : cat a a
Verifying my Blockstack ID is secured with the address 1Ec6qRCQRbNmTAc8DY5TN3o9bd15dxrVPN https://explorer.blockstack.org/address/1Ec6qRCQRbNmTAc8DY5TN3o9bd15dxrVPN
@sellout
sellout / metamorphism.hs
Last active January 3, 2023 16:06
Trying to generalize [metamorphisms](http://www.cs.ox.ac.uk/jeremy.gibbons/publications/metamorphisms-scp.pdf) away from lists.
-- | A “flushing” 'stream', with an additional coalgebra for flushing the
-- remaining values after the input has been consumed. This also allows us to
-- generalize the output away from lists.
fstream
:: (Cursive t (XNor a), Cursive u f, Corecursive u f, Traversable f)
=> Coalgebra f b -> (b -> a -> b) -> Coalgebra f b -> b -> t -> u
fstream ψ g ψ' = go
where
go c x =
let fb = ψ c
@sellout
sellout / Polys.idr
Last active September 18, 2017 04:38
module Polys
import Control.Monad.Identity
import Data.Morphisms
data ProductMeh: (Type -> Type) -> (Type -> Type) -> Type -> Type where
Prod: (f a, g a) -> ProductMeh f g a
data NaturalTransformation : (Type -> Type) -> (Type -> Type) -> Type where
NT : (f a -> g a) -> NaturalTransformation f g
> darwin-rebuild switch ~/.nix-defexpr/darwin
building the system configuration...
error: file ‘darwin’ was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:1
error: Changed <darwin> but target does not exist, aborting activation
Add the darwin repo as a channel or set NIX_PATH:
$ sudo nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
$ sudo nix-channel --update
or set
module Example
interface Base (f : x -> Type) where
base : (x -> Type) -> x -> Type
interface Base f => Corecursive (f : x -> Type) where
cbase : (x -> Type) -> x -> Type
cbase {f} = base {f}
-- When checking right hand side of Example.default#cbase with expected type
@typeclass trait ExpandMapFunc[IN[_]] {
type T[_[_]]
type OUT[_]
def expand: Algebra[IN, T[OUT]]
}
object ExpandMapFunc extends ExpandMapFuncInstances {
type Aux[Tʹ[_[_]], IN[_], OUTʹ[_]] = ExpandMapFunc[IN] {
type T[F[_]] = Tʹ[F]
> nix-channel --update
downloading Nix expressions from ‘https://d3g5gsiof5omrk.cloudfront.net/nixpkgs/nixpkgs-17.09pre106045.7369fd0b51/nixexprs.tar.xz’...
downloading ‘https://d3g5gsiof5omrk.cloudfront.net/nixpkgs/nixpkgs-17.09pre106045.7369fd0b51/nixexprs.tar.xz’... [7471/8550 KiB, 7391.9 KiB/s]
error: cannot connect to daemon at ‘/nix/var/nix/daemon-socket/socket’: Connection refused
cannot fetch ‘https://d3g5gsiof5omrk.cloudfront.net/nixpkgs/nixpkgs-17.09pre106045.7369fd0b51/nixexprs.tar.xz’
> nix-daemon
error: cannot bind to socket ‘/nix/var/nix/daemon-socket/socket’: Address already in use