Skip to content

Instantly share code, notes, and snippets.

@tanakh
Created February 22, 2012 11:06
Show Gist options
  • Save tanakh/1884179 to your computer and use it in GitHub Desktop.
Save tanakh/1884179 to your computer and use it in GitHub Desktop.
{-# LANGUAGE TemplateHaskell #-}
module IP where
import Control.Applicative
import Language.Haskell.TH
import Network
ipPortFile :: FilePath -> Q Exp
ipPortFile fp = do
[ip, port] <- runIO $ lines <$> readFile fp
let port' = read port :: Int
[| (ip, PortNumber $ fromIntegral port') |]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment