This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell #-} | |
module Application where | |
import Control.Lens | |
import Snap.Snaplet | |
import Snap.Snaplet.Heist (Heist, HasHeist(..)) | |
data App = App | |
{ _heist :: Snaplet (Heist App) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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)’, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bistrength g where | |
bistrength :: Bifunctor f => g (f a b) -> f (g a) (g b) | |
instance Bistrength ((,) x) where | |
bistrength (x, f) = bimap (x,) (x,) f | |
instance Bistrength ((,,) x y) where | |
bistrength (x, y, f) = bimap (x,y,) (x,y,) f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 () |
OlderNewer