LoginSignup
11
11

More than 5 years have passed since last update.

いまどきのHaskellのTCPクライアント

Last updated at Posted at 2012-04-05
{-# 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        
  source $= C.lines $$ C.mapM_ $ \line ->                                 
    B.putStrLn line                                                       

すごくいい感じなんだけど、やっぱちょろっと書くにはimportが多いなあ。

11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11