Skip to content

Instantly share code, notes, and snippets.

bird
----
> {-# LANGUAGE GADTs, TypeSynonymInstances #-}
> module ArcChallenge where
>
> import Control.Applicative
> import Control.Applicative.Error (Failing (..))
> import Control.Monad (ap)
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
literate haskell test
> {-# LANGUAGE RankNTypes, KindSignatures #-}
> module ArcChallenge where
>
> import Control.Applicative
> module ArcChallenge where
>
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 {
{-# 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]
{-# 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
@tonyday567
tonyday567 / core-cloud.hs
Created March 26, 2014 21:29
core-cloud.hs
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
vcStd :: Managed (View C.ByteString, Controller C.ByteString)
vcStd = ((,) <$> pure (contramap show MVC.stdoutLines) <*> fmap C.pack <$> MVC.stdinLines)
{-# 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
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE FlexibleInstances #-}
module Pipes.Getter where