This file contains hidden or 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
| mayhem :: [(IO (), IO ())] -> IO () | |
| mayhem xs = do | |
| forM_ xs $ \(event, reaction) -> fork $ forever $ do | |
| event >> reaction | |
| forever $ threadDelay $ 10 ^ 6 |
This file contains hidden or 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
| hoge :: Sink i m r -> Source m o -> Conduit i m o |
This file contains hidden or 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 #-} | |
| import Data.ByteString.Char8 as B | |
| import Data.Conduit | |
| import Data.Conduit.Binary as C | |
| import Data.Conduit.List as C | |
| import Data.Conduit.Network | |
| main :: IO () | |
| main = runTCPClient (ClientSettings 80 "tanakh.jp") $ \source sink -> do | |
| sourceList ["GET / HTTP/1.0\r\nHost: tanakh.jp\r\n\r\n"] $$ sink |
This file contains hidden or 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, QuasiQuotes #-} | |
| import Control.Applicative | |
| import Control.Monad | |
| import qualified Data.ByteString.Lazy.Char8 as B | |
| import Network.HTTP.Conduit | |
| import System.Cmd | |
| import System.Environment | |
| import System.Process.QQ | |
| import Text.HTML.TagSoup |
This file contains hidden or 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 FlexibleContexts #-} | |
| import Control.Applicative | |
| import Control.Monad.Memo | |
| f :: (Functor m, Applicative m, MonadMemo Int Float m) | |
| => (Int -> m Float) | |
| -> (Int -> m Float) | |
| -> (Int -> m Float) | |
| f a b 0 = (/) <$> memo a 0 <*> memo b 0 | |
| f a b n = do |
This file contains hidden or 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
| ____ ____ U _____ u _ _ ____ U ___ u | |
| | _"\ U /"___|u\| ___"|/| \ |"| U /"___|u \/"_ \/ | |
| /| | | | \| | _ / | _|" <| \| |>\| | _ / | | | | | |
| U| |_| |\ | |_| | | |___ U| |\ |u | |_| |.-,_| |_| | | |
| |____/ u \____| |_____| |_| \_| \____| \_)-\___/ | |
| |||_ _)(|_ << >> || \\,-._)(|_ \\ | |
| (__)_) (__)__) (__) (__)(_") (_/(__)__) (__) |
This file contains hidden or 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
| Prelude> import qualified Data.ByteString as B | |
| Prelude B> B.length $ B.replicate (10^12) 0 | |
| Loading package bytestring-0.9.2.1 ... linking ... done. | |
| <interactive>: out of memory (requested 1000000716800 bytes) |
This file contains hidden or 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.Applicative | |
| import Data.List | |
| import Data.Numbers.Primes | |
| main :: IO () | |
| main = do | |
| [n, m] <- map read . words <$> getLine | |
| let factors = group $ primeFactors $ abs n | |
| ans = product (map (h m . genericLength) factors) * 2 ^ (m - 1) | |
| print $ (ans :: Integer) `mod` 1000000007 |
This file contains hidden or 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 | |
| import Control.Monad.Cont | |
| main :: IO () | |
| main = do | |
| (`runContT` const (return ())) $ do | |
| callCC $ \k -> do | |
| forM_ [1..10] $ \i -> do | |
| when (i > 5) $ k () | |
| liftIO $ print i |
This file contains hidden or 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, UndecidableInstances, OverlappingInstances #-} | |
| import Control.Applicative | |
| import Control.Exception.Lifted | |
| import Control.Monad.State | |
| import Control.Monad.Trans | |
| import Control.Monad.Trans.Control | |
| import Prelude hiding (catch) |