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 BangPatterns #-} | |
module Main where | |
zipWith' :: (t -> t1 -> a) -> [t] -> [t1] -> [a] | |
zipWith' f (!x:xs) (!y:ys) = f x y : zipWith' f xs ys | |
zipWith' _ _ _ = [] | |
fibs :: [Integer] | |
fibs = 0 : 1 : zipWith' (+) fibs (tail fibs) |
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
-- See http://bit.ly/kqOh4B | |
module Main | |
where | |
import Control.Arrow | |
import Data.Char | |
zeroOrOne :: Char -> Bool | |
zeroOrOne = uncurry (||) . ((==) 1 &&& (==) 0) . digitToInt |
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 #-} | |
module Main | |
where | |
import Control.Applicative | |
import Control.Monad (mzero) | |
import qualified Data.ByteString as B | |
import qualified Data.Map as M |
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
sharingMap1 :: [([a], a, Maybe a)] -> (# Bool, [a] #) | |
sharingMap1 [] = (# False, [] #); | |
sharingMap1 ((ds_diz, y1_adI, Nothing):ys) = | |
let (# ww1_skq, ww2_skr #) = sharingMap1 ys | |
in case ww1_skq of { | |
False -> (# False, ds_diz #); | |
True -> (# True, (y1_adI:ww2_skr) #) | |
} | |
sharingMap1 ((ds_diz, y1_adI, Just y2):ys) = | |
let (# ww1_skq, ww2_skr #) = sharingMap1 ys |
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.Monad | |
import Control.Concurrent | |
import System.IO | |
import System.Process | |
yesThread :: Int -> Chan String -> IO () | |
yesThread n c = do (_, out, _, _) <- runInteractiveCommand "yes" |
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 TypeFamilies, MultiParamTypeClasses #-} | |
module Main | |
where | |
import Control.Monad ( liftM ) | |
import Data.Char | |
import qualified Data.Vector.Unboxed as V | |
import Data.Vector.Generic as G | |
import qualified Data.Vector.Generic.Mutable as M |
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
$ cabal install -j2 transformers quickcheck | |
Resolving dependencies... | |
[1] Downloading QuickCheck-2.4.1.1... | |
[2] Downloading transformers-0.2.2.0... | |
[2] Configuring transformers-0.2.2.0... | |
[1] Configuring QuickCheck-2.4.1.1... | |
[2] Building transformers-0.2.2.0... | |
[2] Preprocessing library transformers-0.2.2.0... | |
[1] Building QuickCheck-2.4.1.1... | |
[1] Preprocessing library QuickCheck-2.4.1.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
module Main | |
where | |
import Control.Monad.Error | |
data ConfiguredPackage = ConfiguredPackage | |
data FetchStepOutput = FetchStepOutput | |
data BuildStepOutput = BuildStepOutput | |
data BuildResult = BuildResult |
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 #-} | |
-- See | |
-- http://stackoverflow.com/questions/7800272/trying-to-parse-recursive-json-am-i-on-the-right-track/7800464 | |
import Control.Applicative | |
import Control.Monad | |
import Data.Aeson | |
import Data.Attoparsec | |
import qualified Data.ByteString as 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
type Title = String | |
type Author = String | |
data Product = Book Title Author | |
| Video Author | |
| CD Title Integer Author | |
deriving (Eq,Show) | |
getTitle (Book title _ ) = title | |
getTitle (Video title ) = title | |
getTitle (CD title _ _ ) =title |