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
import Data.List | |
import Test.QuickCheck | |
import Test.QuickCheck.Checkers | |
-- catamorphisms | |
cata :: b -> (a -> b -> b) -> [a] -> b | |
cata b f [] = b | |
cata b f (a:as) = f a (cata b f as) | |
cataLength :: [a] -> Int |
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
-- ghc --make -O2 -prof -auto-all -caf-all -fforce-recomp lazyio-single.hs | |
module Main where | |
import Data.ByteString.Lazy (ByteString) | |
import qualified Data.ByteString.Lazy.Char8 as BS (readFile, putStr) | |
import System.Environment (getArgs) | |
main :: IO () | |
main = do | |
(f:_) <- getArgs | |
c <- BS.readFile f |
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
-- ghc --make -O2 -prof -auto-all -caf-all -fforce-recomp lazyio-leaky.hs | |
module Main where | |
import Data.ByteString.Lazy (ByteString) | |
import qualified Data.ByteString.Lazy.Char8 as BS (readFile, putStr) | |
import System.Environment (getArgs) | |
main :: IO () | |
main = do | |
(f:_) <- getArgs | |
c <- BS.readFile f |
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
-- ghc --make -O2 -prof -auto-all -caf-all -fforce-recomp lazyio-double.hs | |
module Main where | |
import Data.ByteString.Lazy (ByteString) | |
import qualified Data.ByteString.Lazy.Char8 as BS (readFile, putStr) | |
import System.Environment (getArgs) | |
main :: IO () | |
main = do | |
(f:_) <- getArgs | |
c <- BS.readFile f |
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
-- ghc --make -O2 -prof -auto-all -caf-all -fforce-recomp lazyio-forkIO.hs | |
module Main where | |
import Data.ByteString.Lazy (ByteString) | |
import qualified Data.ByteString.Lazy.Char8 as BS (readFile, putStr) | |
import System.Environment (getArgs) | |
import Control.Concurrent (forkIO) | |
main :: IO () | |
main = do | |
(f:_) <- getArgs |
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
-- ghc --make -O2 -prof -auto-all -caf-all -fforce-recomp lazyio-forkIO-unbalanced.hs | |
module Main where | |
import Data.ByteString.Lazy (ByteString) | |
import qualified Data.ByteString.Lazy.Char8 as BS (readFile, putStr, unpack) | |
import System.Environment (getArgs) | |
import Control.Concurrent (forkIO) | |
main :: IO () | |
main = do | |
(f:_) <- getArgs |
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
import Data.List (foldl') | |
import Data.Map (Map) | |
import qualified Data.Map as M | |
import System.Environment | |
type Log = String | |
type IPAddr = String | |
type Frequency = Int | |
pageViews :: Integer -> Log -> Integer |
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
user=> (use 'clojure.contrib.logging) | |
nil | |
user=> (info "foo-info") | |
2010/03/25 23:21:23 clojure.contrib.logging$eval__92$impl_write_BANG___100 invoke | |
情報: foo-info | |
nil | |
user=> (fatal "foo-fatal") | |
2010/03/25 23:21:32 clojure.contrib.logging$eval__92$impl_write_BANG___100 invoke | |
致命的: foo-fatal | |
nil |
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
:set -i./src -i./bin | |
-- Read GHCI commands from the file whose name is | |
-- in the GHCIRC environment variable | |
:def _load const(System.Environment.getEnvironment>>=maybe(return"")readFile.lookup"GHCIRC") | |
:_load | |
:undef _load | |
:def hoogle \str -> return $ ":! hoogle --count=15 \"" ++ str ++ "\"" | |
-- <http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/dot-squashed.ghci641> | |
let { redir varcmd = case break Data.Char.isSpace varcmd of { (var,_:cmd) -> return $ unlines [":set -fno-print-bind-result","tmp <- System.Directory.getTemporaryDirectory","(f,h) <- System.IO.openTempFile tmp \"ghci\"","sto <- GHC.Handle.hDuplicate System.IO.stdout","GHC.Handle.hDuplicateTo h System.IO.stdout","System.IO.hClose h",cmd,"GHC.Handle.hDuplicateTo sto System.IO.stdout","let readFileNow f = readFile f >>= \\t->length t `seq` return t",var++" <- readFileNow f","System.Directory.removeFile f"]; _ -> return "putStrLn \"usage: :redir <var> <cmd>\"" } } | |
:def redir redir |
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
:set -i./src -i./bin | |
-- Read GHCI commands from the file whose name is | |
-- in the GHCIRC environment variable | |
:def _load const(System.Environment.getEnvironment>>=maybe(return"")readFile.lookup"GHCIRC") | |
:_load | |
:undef _load | |
:def hoogle \str -> return $ ":! hoogle --count=15 \"" ++ str ++ "\"" | |
-- <http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/dot-squashed.ghci641> | |
let { redir varcmd = case break Data.Char.isSpace varcmd of { (var,_:cmd) -> return $ unlines [":set -fno-print-bind-result","tmp <- System.Directory.getTemporaryDirectory","(f,h) <- System.IO.openTempFile tmp \"ghci\"","sto <- GHC.Handle.hDuplicate System.IO.stdout","GHC.Handle.hDuplicateTo h System.IO.stdout","System.IO.hClose h",cmd,"GHC.Handle.hDuplicateTo sto System.IO.stdout","let readFileNow f = readFile f >>= \\t->length t `seq` return t",var++" <- readFileNow f","System.Directory.removeFile f"]; _ -> return "putStrLn \"usage: :redir <var> <cmd>\"" } } | |
:def redir redir |
OlderNewer