The organizer dedicated to changing the life of a particular community must first rub raw the resentments of the people of the community; fan the latent hostilities of many of the people to the point of overt expression. [They] must search out controversy and issues, rather than avoid them, for unless there is controversy people are not concerned enough to act.
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 GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
-- | | |
module Data.Torrent where | |
import Control.Applicative | |
import Control.Lens | |
import Data.AttoBencode |
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
data Thing = Thing | |
{ _foo :: Int | |
, _bar :: String } | |
buildFoo :: Other -> Thing | |
buildfoo = Thing <$> buildFoo | |
<*> buildBar | |
where buildFoo :: Other -> Int | |
buildFoo = undefined | |
buildBar :: Other -> String |
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
class Renderable a where | |
render :: a -> IO () | |
newtype Rectangle = Rectangle { width :: Double, height :: Double } | |
instance Renderable Rectangle where | |
render = undefined | |
newtype Circle = Circle { radius :: Double } |
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
Average Semigroup | |
================= | |
> {-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
> | |
> module Average where | |
> | |
> import Data.Semigroup | |
> import Data.Ratio (Ratio, (%)) |
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
module ZSCII | |
( decode | |
, encode | |
) where | |
import Control.Applicative ((<$>), (<*>)) | |
import Control.Monad ((<=<)) | |
import Data.Binary.Put | |
import Data.Bits | |
import qualified Data.ByteString.Lazy as BL |
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
encode :: [Word8] => BL.ByteString | |
encode = runPut . putZSCII | |
putZSCII :: [Word8] -> Put | |
putZSCII zstring = do | |
mapM_ | |
(putWord16be . encodeZchar) | |
(chunksOf 3 zstring) | |
putWord16be 0xb1000000000000000 |
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
nexts :: Game -> [Game] | |
nexts game | |
| isNothing (result game) = mapMaybe (update game) allMoves | |
| otherwise = [] | |
type GameTree = Cofree [] Game | |
gameTree :: Game -> GameTree | |
gameTree = coiter nexts |
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
oxfordian [] = "" | |
oxfordian [x] = x | |
oxfordian [x,y] = x ++ " and " ++ y | |
oxfordian [x,y,z] = x ++ ", " ++ y ++ ", and " ++ z | |
oxfordian (x:xs) = x ++ ", " ++ oxfordian xs |
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 Prelude hiding (length, replicate) | |
import Data.Vector hiding ((!), mapM_, take) | |
import qualified Data.Vector as V ((!?)) | |
import Data.Monoid | |
type Cell = Char | |
type Universe = Vector Cell | |
size :: Int | |
size = 30 |