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 |
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
tRemote :: Int -> IO () | |
tRemote n = do | |
backend0 <- initializeBackend host portSlave rtable | |
node0 <- newLocalNode backend0 | |
backend <- initializeBackend host portMaster rtable | |
node <- newLocalNode backend | |
Node.runProcess node (remotePipe' n (Node.localNodeId node0)) | |
where | |
rtable :: RemoteTable | |
rtable = __remoteTable initRemoteTable |
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
vcStd :: Managed (View C.ByteString, Controller C.ByteString) | |
vcStd = ((,) <$> pure (contramap show MVC.stdoutLines) <*> fmap C.pack <$> MVC.stdinLines) |
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 OverloadedStrings #-} | |
{-# LANGUAGE RankNTypes #-} | |
module TestMVC where | |
import Control.Category hiding ((.),id) | |
import qualified MVC.Prelude as MVC | |
import MVC | |
import qualified Pipes.Prelude as Pipes | |
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 RankNTypes #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
module Pipes.Getter where |
OlderNewer