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 ExistentialQuantification #-} | |
{-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-unused-do-bind -fno-warn-unused-imports -fno-warn-orphans #-} | |
module Main where | |
import Control.Applicative | |
import Data.List (foldl') | |
import Data.Monoid | |
import Data.Strict.Tuple | |
import Prelude hiding (sum, length) |
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 Main where | |
import Control.Concurrent hiding (yield) | |
import Control.Concurrent.Chan | |
import Data.Char (chr) | |
import Data.Maybe | |
import Control.Monad | |
import Control.Monad.Random ( RandomGen, Rand, getRandomR, evalRandIO) | |
import Control.Monad.Trans.State.Strict (StateT, get, put, evalStateT) | |
import Data.List |
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 RankNTypes #-} | |
{-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-unused-do-bind -fno-warn-unused-imports -fno-warn-orphans #-} | |
-- | |
-- Random walk emitter with go and stop button | |
-- | |
module Main where | |
import Control.Applicative |
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 Arrows #-} | |
import Prelude hiding ((.), id) | |
import Control.Arrow (Arrow(arr, first), ArrowChoice(left)) | |
import Control.Category (Category((.), id)) | |
import Control.Foldl | |
import Control.Monad ((>=>)) | |
import Control.Monad.Trans.State.Strict (get, put) | |
import Pipes |
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
bird | |
---- | |
> {-# LANGUAGE GADTs, TypeSynonymInstances #-} | |
> module ArcChallenge where | |
> | |
> import Control.Applicative | |
> import Control.Applicative.Error (Failing (..)) | |
> import Control.Monad (ap) |
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
In this gist we will first show that we can beat the arc challenge | |
(http://www.paulgraham.com/arcchallenge.html), and then build the library that | |
shows how we did it. This gist is Literate Haskell and is of course executable. The packages needed are happstack-server and applicative-extras, installable using cabal. | |
Let's start with some imports (for now, you can ignore these) | |
> {-# LANGUAGE GADTs, TypeSynonymInstances #-} | |
> module ArcChallenge where | |
> | |
> import Control.Applicative |
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
literate haskell test | |
> {-# LANGUAGE RankNTypes, KindSignatures #-} | |
> module ArcChallenge where | |
> | |
> import Control.Applicative | |
> module ArcChallenge 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
body { | |
font-family: Helvetica, arial, sans-serif; | |
font-size: 14px; | |
line-height: 1.6; | |
padding-top: 10px; | |
padding-bottom: 10px; | |
background-color: white; | |
padding: 30px; } | |
body > *:first-child { |
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 ExistentialQuantification, RankNTypes #-} | |
module Scanl where | |
import Control.Foldl (Fold(..)) | |
import Data.Foldable (Foldable) | |
import qualified Data.Foldable as F | |
import Data.Traversable | |
scan :: (Foldable f) => Fold a b -> f a -> [b] |
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 DeriveGeneric #-} | |
{-# LANGUAGE DefaultSignatures #-} | |
import GHC.Generics | |
import Control.Applicative | |
import Data.Text.Encoding | |
import Data.Aeson | |
import Data.Aeson.Types | |
import qualified Data.ByteString as B | |
import qualified Data.ByteString.Lazy as LB |