@Sakae has joined the channel
callCC
の型はなぜ`forall r m a. ((forall b. a -> ContT r m b) -> ContT r m a) -> ContT r m a`ではなく`forall r m a b. ((a -> ContT r m b) -> ContT r m a) -> ContT r m a`なのでしょうかvector-13.0.0
における newtype
に対する Unbox
実装の質問です。U.Vector
を使うだけなら、大きな差は無いと思って良いでしょうか。RecordWildCards
有効にすると、RecordWildCards
を有効にすると暗黙に有効にされるDisambiguateRecordFields
の効果なのかと思ったけどそういうわけでもないみたいです.module M where data R = R { x :: String }
{-# LANGUAGE RecordWildCards #-} import M inc :: Int -> Int inc x = x + 1 getX :: R -> String getX m = x m
data FunDecl = FunDecl String [([Pattern], Expr)]
Haskell timeout :: Int -> IO a -> IO (Maybe a) timeout n f | n < 0 = fmap Just f | n == 0 = return Nothing | otherwise = do -- In the threaded RTS, we use the Timer Manager to delay the -- (fairly expensive) 'forkIO' call until the timeout has expired. -- -- An additional thread is required for the actual delivery of -- the Timeout exception because killThread (or another throwTo) -- is the only way to reliably interrupt a throwTo in flight. pid <- myThreadId ex <- fmap Timeout newUnique tm <- getSystemTimerManager -- 'lock' synchronizes the timeout handler and the main thread: -- * the main thread can disable the handler by writing to 'lock'; -- * the handler communicates the spawned thread's id through 'lock'. -- These two cases are mutually exclusive. lock <- newEmptyMVar let handleTimeout = do v <- isEmptyMVar lock when v $ void $ forkIOWithUnmask $ \unmask -> unmask $ do v2 <- tryPutMVar lock =<< myThreadId when v2 $ throwTo pid ex cleanupTimeout key = uninterruptibleMask_ $ do v <- tryPutMVar lock undefined if v then unregisterTimeout tm key else takeMVar lock >>= killThread handleJust (\e -> if e == ex then Just () else Nothing) (\_ -> return Nothing) (bracket (registerTimeout tm n handleTimeout) cleanupTimeout (\_ -> fmap Just f))