This file contains hidden or 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, GeneralizedNewtypeDeriving #-} | |
import System.FilePath (FilePath, (</>)) | |
import System.Directory (getDirectoryContents, doesFileExist) | |
import Control.Monad | |
import Control.Monad.State | |
import Control.Monad.Reader | |
import Control.Monad.Writer | |
type St = Int | |
data Conf = Conf { |
This file contains hidden or 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 FlexibleInstances, TypeSynonymInstances, RankNTypes, OverloadedStrings #-} | |
import Data.Data | |
import Data.Aeson hiding (toJSON, fromJSON) | |
import Data.Aeson.Generic | |
import Data.Attoparsec | |
import qualified Data.ByteString as B | |
data MethodCall = MethodCall String [Value] | |
deriving (Eq, Show) |
This file contains hidden or 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
diff --git a/bootstrap.sh b/bootstrap.sh | |
index b9950e7..105b693 100644 | |
--- a/bootstrap.sh | |
+++ b/bootstrap.sh | |
@@ -19,7 +19,7 @@ CURL=${CURL:-curl} | |
FETCH=${FETCH:-fetch} | |
TAR=${TAR:-tar} | |
GUNZIP=${GUNZIP:-gunzip} | |
-SCOPE_OF_INSTALLATION="--user" | |
+SCOPE_OF_INSTALLATION="--global" |
This file contains hidden or 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 (catch) | |
import System.Environment | |
import System.IO | |
import System.Directory | |
import System.FilePath | |
import Control.Exception | |
import Control.Applicative | |
import Control.Monad | |
import Data.List |
This file contains hidden or 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 (lookup) | |
import Data.Maybe (fromMaybe) | |
import qualified Data.Map as M | |
import Control.Monad (join) | |
data Trie c a = Trie | |
(Maybe a) -- node may or may not contain a value. | |
(M.Map c (Trie c a)) | |
deriving (Show) |
This file contains hidden or 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 Criterion.Main | |
next :: Int -> Int | |
next n | even n = n `div` 2 | |
| otherwise = 3*n+1 | |
len :: Int -> Int | |
len = length . takeWhile (/=1) . iterate next | |
len' :: Int -> Int -> Int |
This file contains hidden or 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, ViewPatterns #-} | |
import System.Environment (getArgs) | |
import Control.Monad | |
import Control.Monad.ST | |
import Data.STRef | |
import GHC.Int | |
fib1 :: Int -> Integer | |
fib1 n = fibs !! n | |
where fibs = 1:1:zipWith (+) fibs (tail fibs) |
This file contains hidden or 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 (fib1, fib2, fib3, fib4, main) where | |
import Control.Monad | |
import Control.Monad.ST | |
import Data.STRef | |
import Criterion.Main | |
fib1 :: Int -> Integer | |
fib1 n = fst $ fib' n | |
where fib' 0 = (1, 1) |
This file contains hidden or 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 DList where | |
import Prelude hiding (reverse) | |
import Prelude as P | |
{- | |
- provide whatever list operation in O(1) time complexity ... | |
- only toList do all the hard works. | |
-} |
This file contains hidden or 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 System.Environment | |
import Data.List (intersperse) | |
split :: Int -> [[Int]] | |
split x = go x 1 | |
where | |
go 0 _ = [[]] | |
go n i = flip concatMap [i..n] $ \i' -> | |
map (i':) $ go (n-i') i' |
OlderNewer