Skip to content

Instantly share code, notes, and snippets.

To allow hask

type Cat k = k -> k -> Type

type Fun i j = i -> j

data Nat :: Cat i -> Cat j -> Cat (Fun i j) where
  Nat :: (FunctorOf cat cat' f, FunctorOf cat cat' f') => (forall a. Ob cat a => cat' (f a) (f' a)) -> Cat cat cat' f f'
@Icelandjack
Icelandjack / Trac_10843.markdown
Last active June 13, 2017 12:51
GHC Trac #10843
@Icelandjack
Icelandjack / Category_Theory.markdown
Last active January 6, 2019 14:45
Category Theory: "Think bigger thoughts"

http://www.cs.ox.ac.uk/people/bob.coecke/AbrNikos.pdf

Why study categories—what are they good for? We can offer a range of answers for readers coming from different backgrounds:

  • For mathematicians: category theory organises your previous mathematical experience in a new and powerful way, revealing new connections and structure, and allows you to “think bigger thoughts”.
  • For computer scientists: category theory gives a precise handle on important notions such as compositionality, abstraction, representationindependence, genericity and more. Otherwise put, it provides the fundamental mathematical structures underpinning many key programming concepts.
  • For logicians: category theory gives a syntax-independent view of the fundamental structures of logic, and opens up new kinds of models and interpretations.
  • For philosophers: category theory opens up a fresh approach to structuralist foundations of mathematics and science; and an alternative to the traditional focus on set theory
  • For **p
@Icelandjack
Icelandjack / Code.markdown
Created June 2, 2017 14:46
TODO: Look at when on laptop
@Icelandjack
Icelandjack / irc.log
Created June 1, 2017 15:56
Implication constraints, Show1, Eq1, Read1, Ord1
mniip
edwardk, I think I just came up with the most complicated solution to the Show1 problem
phadej
Show1 problem?
mniip
instance Show (IdentityT m a) where ???
phadej
and your solution is?
mniip
coming up
@Icelandjack
Icelandjack / Deriving.hs
Last active July 2, 2017 13:42
Template Haskell deriving, first implementation
{-# Language InstanceSigs, ViewPatterns, TupleSections, GeneralizedNewtypeDeriving, TemplateHaskell, LambdaCase #-}
module D where
import Language.Haskell.TH
import Data.Coerce
deriveVia :: Name -> Name -> Name -> Q [Dec]
deriveVia className ty viaNewTy = do
a <- reify className
@Icelandjack
Icelandjack / id.markdown
Last active June 25, 2017 06:59
Identity function, id :: a -> a

Principle of identity expansion

Whenever some construction has a certain relationship to all constructions of the same kind within a category, it must, in particular, have this relationship to itself. Socrates’ dictum to “know thyself” is as important in category theory as it is in life. So whenever we encounter a universal construction we will see what we can learn about it by “probing it with itself”. In the case of a terminal object, this means choosing X ≔ T in the definition.

Lemma 3.1.1.2 (identity expansion for terminals) If T is a terminal object then !(T) = id(T).

Lemma 3.1.4.2 (identity expansion for initials) If S is an initial object then ¡(S) = id(S).