Skip to content

Instantly share code, notes, and snippets.

@Icelandjack
Icelandjack / SystemF.markdown
Created December 15, 2017 23:16
Embedding System F
@Icelandjack
Icelandjack / OpenKinds.markdown
Last active January 26, 2020 20:53
Rethinking Tricky Classes: Explicit Witnesses of Monoid Actions, Semigroup / Monoid / Applicative homomorphisms
@Icelandjack
Icelandjack / ExtensibleIsomorphisms.markdown
Last active January 8, 2018 16:56
Encoding Overlapping, Extensible Isomorphisms
@Icelandjack
Icelandjack / Singletons.hs
Last active November 29, 2017 13:08
Functor over type functions
{-# Language StandaloneDeriving, PatternSynonyms, GADTs, UndecidableInstances, ScopedTypeVariables, TemplateHaskell, TypeInType, TypeOperators, TypeFamilies, AllowAmbiguousTypes, InstanceSigs, TypeApplications #-}
import Data.Singletons
import Data.Singletons.Prelude.Base
import Data.Singletons.TH
import Data.Kind
import Control.Arrow ((***))
data Dup :: Type ~> Type
@Icelandjack
Icelandjack / CCC.md
Last active October 2, 2017 07:59
CCC talking points

Free Categories

You can build categories just by connecting objects with arrows. You can imagine starting with any directed graph and making it into a category by simply adding more arrows. First, add an identity arrow at each node. Then, for any two arrows such that the end of one coincides with the beginning of the other (in other words, any two composable arrows), add a new arrow to serve as their composition. Every time you add a new arrow, you have to also consider its composition with any other arrow (except for the identity arrows) and itself. You usually end up with infinitely many arrows, but that’s okay.

Another way of looking at this process is that you’re creating a category, which has an object for every node in the graph, and all possible chains of composable graph edges as morphisms. (You may even consider identity morphisms as special cases of chains of length zero.)

Such a category is called a free category generated by a given graph. It’s an example of a free construction, a proces

@Icelandjack
Icelandjack / gist:1a57ae22fe221ef9a67c96dc24b4751f
Created September 28, 2017 10:54
TODO Divisible implement later
@Icelandjack
Icelandjack / Paper.md
Created September 23, 2017 16:52
Paper: Stuff that has to be mentioned

This would be sweet to have:

instance Category cat => Monoid (Join cat a) where
  mempty = Join id

  Join f `mappend` Join g = Join (f . g)

and where we can define

@Icelandjack
Icelandjack / Row_types.markdown
Last active March 13, 2019 03:51
Row Types for Type Classes

Type classes in terms of row types

type Semigroup s = { Monoid s with mappend :: s -> s -> s | _ }

type Pointed f = { Applicative f with pure  :: forall a. a -> f a | _ }
type Apply   f = { Applicative f with (<*>) :: forall a b. f (a -> b) -> f a -> f b | _ }
type Bind    m = { Monad       m with (>>=) :: forall a b. m a -> (a -> m b) -> m b | _ }
@Icelandjack
Icelandjack / Binary.hs
Created September 1, 2017 09:37 — forked from ndmitchell/Binary.hs
Binary existentials
{-# LANGUAGE StaticPointers #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Binary
import Data.Typeable
import System.IO.Unsafe
import GHC.StaticPtr
@Icelandjack
Icelandjack / Ran.markdown
Last active November 13, 2020 20:51
Right Kan extensions and Indexed Monads