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
15:26:05 [I] Bootstrapping "project" in "/tmp/event" | |
15:26:05 [I] /tmp/event $ /usr/local/git/bin/git clone -n http://github.com/tibbe/event.git /tmp/event/.gittmp | |
15:26:05 [D] Executing /usr/local/git/bin/git clone -n http://github.com/tibbe/event.git /tmp/event/.gittmp ('/tmp/event') | |
15:26:05 [W] [Status 128] | |
15:26:05 [C] Checkout of project failed! | |
Failure applying upstream changes: /tmp/event $ /usr/local/git/bin/git clone -n http://github.com/tibbe/event.git /tmp/event/.gittmp failed |
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 TimeoutCallback = IO () | |
data EventManager = EventManager | |
{ emTimeouts :: IORef (PSQ TimeoutCallback) | |
, ... | |
} |
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 TimeoutCallback = IO () | |
data EventManager = EventManager | |
{ emTimeouts :: IORef (PSQ TimeoutCallback) | |
, ... | |
} |
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
-- | Register a timeout in the given number of milliseconds. | |
registerTimeout :: EventManager -> Int -> TimeoutCallback -> IO TimeoutKey | |
registerTimeout mgr ms cb = do | |
key <- newUnique (emUniqueSource mgr) | |
now <- getCurrentTime | |
let expTime = fromIntegral ms / 1000.0 + now | |
_ <- atomicModifyIORef (emTimeouts mgr) $ \q -> | |
let q' = Q.insert key expTime cb q in (q', q') | |
wakeManager mgr | |
return $! TK key |
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 TimeoutQueue = Q.PSQ TimeoutCallback | |
type TimeoutEdit = TimeoutQueue -> TimeoutQueue | |
applyTimeoutEdits :: TimeoutQueue -> [TimeoutEdit] -> TimeoutQueue | |
applyTimeoutEdits = foldr ($!) |
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 qualified Data.ByteString.Lazy as S | |
import qualified Data.Text as T | |
import qualified Data.Text.Lazy.Encoding as E | |
import Data.Text.Template |
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
member :: Int -> [Int] -> Bool | |
member _ [] = False | |
member n (x:xs) | |
| x == n = True | |
| otherwise = member n xs |
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
member :: Int -> [Int] -> Bool | |
member n = go | |
where | |
go [] = False | |
go (x:xs) | |
| x == n = True | |
| otherwise = go xs |
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
filter :: (a -> Bool) -> [a] -> [a] | |
filter _ [] = [] | |
filter p (x:xs) | |
| p x = x : filter p xs | |
| otherwise = filter p xs |
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
filter :: (a -> Bool) -> [a] -> [a] | |
filter p = go | |
where | |
go [] = [] | |
go (x:xs) | |
| p x = x : go xs | |
| otherwise = go xs |
OlderNewer