Skip to content

Instantly share code, notes, and snippets.

View aycanirican's full-sized avatar
💭
Lifelong learning

Aycan iRiCAN aycanirican

💭
Lifelong learning
View GitHub Profile
module Fold where
import Test.QuickCheck
op xs = go xs True 0 where
go [] _ acc = acc
go xs@(a:res) True acc = go res False (acc + a)
go xs@(a:res) False acc = go res True (acc - a)
prop_iso xs = foldr (-) 0 xs ≡ op xs
type ErrMsg = SomeException
data Stream el = EOF (Maybe ErrMsg)
| Chunk [el] deriving Show
type Intermediate a el = (a, Stream el)
-- | a: intermediate result
-- r: final result of the CPS computation
newtype ContM r el a = Cont { runCont ∷ (Intermediate a el → r) → r}
-- | throw a timeout exception to the handling thread -- it'll clean up
-- everything
timerCallback :: EvLoopPtr -- ^ loop obj
-> EvTimerPtr -- ^ timer obj
-> IORef CTime -- ^ when to timeout?
-> MVar ThreadId -- ^ thread to kill
-> TimerCallback
timerCallback loop tmr ioref tmv _ _ _ = do
debug "Backend.timerCallback: entered"
evTimerSetRepeat :: EvTimerPtr -> Double -> IO ()
evTimerSetRepeat p t = do
evtimer <- peek p
poke p evtimer { repeat = t }
{-# LANGUAGE TemplateHaskell, TypeFamilies, DeriveDataTypeable,
FlexibleInstances, MultiParamTypeClasses, FlexibleContexts,
UndecidableInstances, TypeOperators
#-}
module App.ObjectStore
( objectStoreHandlers
) where
import Coretal.Services.OpenIDHandlers
-- import Happstack.Data
{-# LANGUAGE OverloadedStrings #-}
module Session
( sessionCookie
, withSession
, newSessionCookie
, session
) where
import Control.Monad.Trans (liftIO)
import Control.Applicative
pRequest' :: Parser IRequest
pRequest' = IRequest
<$> (option "" crlf *> pMethod) <* sp
<*> pUri <* sp
<*> pVersion <* crlf
<*> pHeaders <* crlf
aycan@fgt:~/haskell/snap-server/test$ ./runTestsAndCoverage.sh
Snap.Internal.Http.Parser.Tests:
show: [OK]
parseCookie: [OK]
chunked transfer encoding: [OK, passed 1000 tests]
chunk . unchunk == id: [OK, passed 1000 tests]
testBothChunkedBuffered1: [Failed]
Falsifiable with seed 8872790038128987215, after 2 tests. Reason: Exception: 'control message: Just (Err "not enough bytes")'
testBothChunkedBuffered2: [Failed]
Falsifiable with seed 932625037523277916, after 6 tests. Reason: Exception: 'control message: Just (Err "not enough bytes")'
aycan@fgt:~/haskell/snap-server/test$ ./runTestsAndCoverage.sh
Snap.Internal.Http.Parser.Tests:
show: [OK]
parseCookie: [OK]
chunked transfer encoding: [OK, passed 1000 tests]
chunk . unchunk == id: [OK, passed 1000 tests]
pipelined chunk . unchunk == id: [Failed]
Falsifiable with seed -6342116022785088208, after 12 tests. Reason: Exception: 'control message: Just (Err "not enough bytes")'
testBothChunkedEmpty: [Failed]
ERROR: control message: Just (Err "not enough bytes")
threadDelay :: Int -> IO () Source
Suspends the current thread for a given number of microseconds (GHC only).
There is no guarantee that the thread will be rescheduled promptly when the delay has expired, but the thread will ***never continue to run earlier than specified***.
---
module Main where