Skip to content

Instantly share code, notes, and snippets.

View ChristopherKing42's full-sized avatar

Christopher King ChristopherKing42

  • Milky Way Galaxy
View GitHub Profile
import Graphics.Gloss.Interface.Pure.Game
import Graphics.Gloss.Data.Bitmap
import Data.Monoid
history = 10
cr = green
mult = -1/3
main = loadBMP "explosion4.bmp" >>= \explosion -> play
(InWindow "Velocity" (500,500) (0,0))
import Control.Applicative (liftA2)
import Data.Foldable
import Data.Tuple.Homogenous
import Graphics.Gloss.Interface.Pure.Game
import Debug.Trace
main = play
(InWindow "Deriv II" (500,500) (100,100))
black
{-# LANGUAGE Rank2Types, GADTs #-}
import Data.Map hiding (map, foldr, mapMaybe, filter)
import qualified Data.Map as M
import Data.Maybe
newtype Tree k v = Tree {unTree :: forall r. (v->r) -> (Map k r->r) -> r}
instance Functor (Tree k) where
fmap f (Tree cont) = Tree $ \leaf tree -> cont (leaf . f) tree
{-# LANGUAGE Rank2Types, DeriveFunctor #-}
import Control.Applicative
newtype Regex c a = Reg {unReg :: forall f. (Alternative f) => (c -> f ()) -> f a} deriving (Functor)
instance Applicative (Regex c) where
pure a = Reg (const $ pure a)
(Reg rab) <*> (Reg ra) = Reg (\sym -> (rab sym) <*> (ra sym))
instance Alternative (Regex c) where
{-# LANGUAGE Rank2Types, OverloadedStrings, FlexibleInstances #-}
import Control.Applicative
import Control.Monad
import Data.String
newtype Parser t a = Par {cont :: forall m. MonadPlus m => m t -> m a}
instance Functor (Parser t) where
fmap ab (Par pa) = Par $ \tok -> fmap ab $ pa tok
{-# LANGUAGE DeriveFunctor, FlexibleInstances, RecordWildCards, TupleSections #-}
import Control.Comonad
import Data.Array
data Board a = Board {focus :: (Int,Int), cells :: Array (Int, Int) a} deriving (Functor)
xsize = 167
ysize = 42
rng = ((0,0),(xsize-1,ysize-1))
import Control.Monad
import System.IO
data Game = Guess String | Question String Game Game deriving (Show)
start = Guess "a pineapple"
yesNoQ q = do
putStr q
putChar ' '
{-# LANGUAGE DeriveFunctor, Rank2Types #-}
import Algebra.Lattice
import Algebra.Lattice.Op
import Control.Monad (ap)
import qualified Data.Set as S
newtype Set a = Set {folded :: forall r. BoundedJoinSemiLattice r => (a -> r) -> r} deriving Functor
newtype JoinMonoid a = JM {unJM :: a}