this is refer
This file contains 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
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)) |
This file contains 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
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 |
This file contains 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 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 |
This file contains 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 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 |
This file contains 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 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 |
This file contains 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 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)) |
This file contains 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
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 ' ' |
This file contains 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 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} |
OlderNewer