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 FlexibleInstances, MultiParamTypeClasses, TypeFamilies #-} | |
module AT where | |
{- --- ORIGINAL --- -} | |
data Step s a = Done | |
| Skip !s | |
| Yield !a !s | |
{- --- WITH ATs --- -} |
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 FlexibleInstances, MultiParamTypeClasses, TypeFamilies #-} | |
module AT where | |
{- --- ORIGINAL --- -} | |
data Step s a = Done | |
| Skip !s | |
| Yield !a !s | |
{- --- WITH ATs --- -} |
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
diff -rN -u old-text/Data/Text/Encoding/Fusion/Common.hs new-text/Data/Text/Encoding/Fusion/Common.hs | |
--- old-text/Data/Text/Encoding/Fusion/Common.hs 2010-08-15 12:44:14.251803996 -0700 | |
+++ new-text/Data/Text/Encoding/Fusion/Common.hs 2010-08-15 12:44:14.274804276 -0700 | |
@@ -45,19 +45,19 @@ | |
Done -> Done | |
Skip s' -> Skip (S s' N N N) | |
Yield x xs | |
- | n <= 0x7F -> Yield c (S xs N N N) | |
- | n <= 0x07FF -> Yield a2 (S xs (J b2) N N) | |
- | n <= 0xFFFF -> Yield a3 (S xs (J b3) (J c3) N) |
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 Control.Monad (replicateM_) | |
import qualified Data.ByteString as B | |
import Network.Format.LLSD | |
import System.Environment | |
main = do | |
[path, count] <- getArgs | |
replicateM_ (read count) $ do | |
bs <- B.readFile path | |
case parseXML bs of |
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 Control.Concurrent | |
import Control.Monad | |
import qualified Data.ByteString as B | |
import Network.Format.LLSD | |
import System.Environment | |
main = do | |
[path, threads, reads] <- getArgs | |
let nthreads = read threads | |
qs <- newQSem 0 |
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
src/Snap/Internal/Http/Parser.hs:126:4: | |
Couldn't match expected type `Iteratee IO a' | |
against inferred type `(a1, b)' | |
In the pattern: (out, _) | |
In a stmt of a 'do' expression: | |
(out, _) <- unsafeBufferIterateeWithBuffer | |
buf (ignoreEOF $ wrap killwrap it) | |
In the expression: | |
do { killwrap <- newIORef False; | |
(out, _) <- unsafeBufferIterateeWithBuffer |
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 Foreign.C.String | |
import Foreign.Ptr | |
import System.Posix.Internals | |
debug :: String -> IO () | |
debug s = do | |
withCStringLen (s++"\n") $ \(ptr,len) -> | |
c_safe_write 2 (castPtr ptr) (fromIntegral len) | |
return () |
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
! From http://netlib.org/linalg/html_templates/node98.html | |
! | |
! val: non-zero values from the matrix | |
! col_ind: indices into val at which columns start in successive rows | |
! row_ptr: indices into val at which successive rows start | |
for i = 1, n | |
y(i) = 0 | |
for j = row_ptr(i), row_ptr(i+1) - 1 | |
y(i) = y(i) + val(j) * x(col_ind(j)) |
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
-- Assumption: indices are sorted in ascending order. | |
type Sparse a = [(Int,a)] | |
zipWithS :: (Num a) => (a -> a -> a) -> Sparse a -> Sparse a -> Sparse a | |
zipWithS f as0 bs0 = filter ((/=0) . snd) $ go as0 bs0 | |
where go ias@(ia@(i,a):as) jbs@(jb@(j,b):bs) = | |
case compare i j of | |
LT -> ia : go as jbs | |
EQ -> (i,f a b) : go as bs |
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
{-# OPTIONS_GHC -O2 #-} | |
{-# LANGUAGE BangPatterns, MagicHash, OverloadedStrings, UnboxedTuples #-} | |
module Main (main) where | |
import Data.Monoid (mappend, mempty) | |
import GHC.Base (Int(..), chr, quotInt#, remInt#) | |
import Prelude hiding ((!!)) | |
import System.Environment (getArgs) | |
import qualified Data.ByteString.Char8 as B |
OlderNewer