Skip to content

Instantly share code, notes, and snippets.

@Icelandjack
Icelandjack / 14048.markdown
Created August 3, 2017 01:27
#14048: Data instances of kind Constraint

Hask

LiftC1 :: (k1 -> k2 -> Constraint) -> (k -> k1) -> (k -> k2) -> (k -> Constraint)
Lift1  :: (k1 -> k2 -> Type)       -> (k -> k1) -> (k -> k2) -> (k -> Type)

LiftC2 :: (k1 -> k2 -> k' -> Constraint) -> (k -> k1) -> (k -> k2) -> (k -> k' -> Constraint)
Lift2  :: (k1 -> k2 -> k' -> Type)       -> (k -> k1) -> (k -> k2) -> (k -> k' -> Type)

http://www.eduhk.hk/cte2017/doc/CTE2017%20Proceedings.pdf#page=138

Computational thinking has attracted a lot of attention worldwide in recent years since the publication of Jeannette M. Wing’s (2006) highly influential paper in the Communications of the ACM, in which she argues that the way computer scientists think about the world is useful in other contexts. Wing writes:

Computational thinking involves solving problems, designing systems, and understanding human behavior, by drawing on the concepts fundamental to computer science. Computational thinking includes a range of

@Icelandjack
Icelandjack / checkiffails.hs
Created July 14, 2017 10:21
See if this still fails on GHC 8.2
type Cat k = k -> k -> Type
data T = D | I
type family
Interp (a :: T) :: Type where
Interp I = Int
Interp D = Double
data Fn :: (T, T) -> Type where
@Icelandjack
Icelandjack / ThinkingAbout.markdown
Created July 14, 2017 02:10
[TALK,BLOG,QUOTE] Different ways of thinking about

Compare https://twitter.com/mrkgnaow/status/876007524968800256 to Haskell, should probably stress this before each talk

This is a list of different ways of thinking about or conceiving of the derivative, rather than a list of different logical definitions. Unless great efforts are made to maintain the tone and flavor of the original human insight, the differences start to evaporate as soon as the mental concepts are translated into precise, formal and explicit definitions.

I can remember absorbing each of those concepts as something new and interesting, and spending a good deal of mental time and effort digesting and practicing with each, reconciling it with the others. I also remember coming back to revisit these different concepts later with added meaning and understanding.

@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

@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