Skip to content

Instantly share code, notes, and snippets.

@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 / Code.markdown
Created June 2, 2017 14:46
TODO: Look at when on laptop
@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 / Trac_10843.markdown
Last active June 13, 2017 12:51
GHC Trac #10843

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 / newtype_wrappers.markdown
Last active November 26, 2017 18:19
Newtype wrappers for deriving

Getting Num, Floating, Fractional from Applicative

newtype WrappedApplicative f a = WrapApplicative (f a)
  deriving 
    (Functor, Show)
  deriving newtype 
    Applicative

instance (Applicative f, Num a) => Num (WrappedApplicative f a) where
@Icelandjack
Icelandjack / blog_deriving.markdown
Last active October 7, 2019 22:43
Blog Post: Derive instances of representationally equal types

Reddit discusson thread.

I made a way to get more free stuff and free stuff is good.

The current implementation of deriveVia is here, it works with all the examples here. Needs GHC 8.2 and th-desugar.

It doesn't take long

for new Haskellers to get pampered by their compiler. For the price of a line or two the compiler offers to do your job, to write uninteresting code for you (in the form of type classes) such as equality, comparison, serialization, ... in the case of 3-D vectors