Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@int-index
int-index / Application.hs
Created April 5, 2015 19:08
snap-problem
{-# LANGUAGE TemplateHaskell #-}
module Application where
import Control.Lens
import Snap.Snaplet
import Snap.Snaplet.Heist (Heist, HasHeist(..))
data App = App
{ _heist :: Snaplet (Heist App)
@int-index
int-index / Dynamic.hs
Created April 30, 2015 00:42
instance Num Dynamic
module Dynamic where
import Control.Applicative
import Data.Dynamic
please = maybe (error "dynamic typing is bad :(") toDyn
pleaseApp2 :: (Rational -> Rational -> Rational)
-> (Dynamic -> Dynamic -> Dynamic)
pleaseApp2 f a b = please $ f <$> fromDynamic a <*> fromDynamic b
@int-index
int-index / Bug.hs
Last active August 29, 2015 14:20
GHC 7.10 bug
{-# LANGUAGE PartialTypeSignatures #-}
module Main where
data I a = I a
instance Functor I where
fmap f (I a) = I (f a)
newtype B t a = B a
instance Functor (B t) where
fmap f (B a) = B (f a)
@int-index
int-index / 7.10.3.out
Created May 22, 2016 11:47
Pattern synonyms GHCi 8.0 regression
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
Prelude> :l M.hs
[1 of 1] Compiling Main ( M.hs, interpreted )
Ok, modules loaded: Main.
*Main>
@int-index
int-index / M.hs
Last active May 27, 2016 12:52
Monoid is a one object Category
{-# LANGUAGE NoImplicitPrelude, GADTs, DataKinds, PolyKinds, FlexibleInstances #-}
import Data.Monoid
import Control.Category
-- A monoid gives a rise to a single-object category.
newtype M m (a :: ()) (b :: ()) = M m
instance Monoid m => Category (M m) where
id = M mempty
@int-index
int-index / errors
Last active June 18, 2016 17:40
FieldType
[1 of 1] Compiling Main ( fieldtype.hs, fieldtype.o )
fieldtype.hs:19:27: error:
• Expected kind ‘Fin (FieldCount T)’,
but ‘'FZ’ has kind ‘Fin ('S n0)’
• In the second argument of ‘FieldType’, namely ‘FZ’
In the type instance declaration for ‘FieldType’
fieldtype.hs:20:28: error:
• Expected kind ‘Fin (FieldCount T)’,
@int-index
int-index / polyconstraints-exercise.hs
Last active May 31, 2017 11:07
Polyconstraints Exercise: @int-index solution
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances,
TypeOperators, UndecidableInstances #-}
{-# LANGUAGE RankNTypes, ScopedTypeVariables, ConstraintKinds #-}
import Data.Constraint
import Data.Constraint.Forall
class C1 a b
class C2 a b
instance C1 a b => C2 a b
@int-index
int-index / coherent.hs
Created July 3, 2017 01:11
Coherent Reader
{-# LANGUAGE RankNTypes, ScopedTypeVariables, FlexibleContexts #-}
import Control.Monad.Reader
import Data.Reflection
import Data.Tagged
import Data.Proxy
f :: Reader String Int
f = do
a <- ask
@int-index
int-index / keybase.md
Created November 2, 2017 01:12
keybase.md

Keybase proof

I hereby claim:

  • I am int-index on github.
  • I am int_index (https://keybase.io/int_index) on keybase.
  • I have a public key ASDdpc-5-1Z79PVP06_HBtD5DQ-q0TkrX3nyQs7cIvSEFQo

To claim this, I am signing this object:

@int-index
int-index / nolog.hs
Last active December 14, 2017 12:41
Logging not disabled
{-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleInstances, OverloadedStrings, UndecidableInstances #-}
import Control.Monad.Logger
import Control.Monad.Trans
import Control.Monad.Trans.Identity
import Data.Coerce
class Monad m => MonadFoo m where
foo :: m ()