packages feed

nyan-interpolation-core-0.9: app/Main.hs

import Control.Concurrent
import qualified Data.Text as T
import GHC.IO.Handle
import System.Process

getFileContent :: IO T.Text
getFileContent = withCreateProcess (proc "cat" ["very-big-file.txt"]){ std_out = CreatePipe }
  \_mStdin mStdout _mStderr phandler ->
    case mStdout of
      Nothing     -> error "No handler"
      Just stdout -> do
        putStrLn "Connected, getting"
        !output <- T.pack <$> hGetContents stdout
        res <- waitForProcess phandler
        putStrLn $ "Awaited: " <> show res
        putStrLn $ "Result: " <> show (T.length output)
        threadDelay 100000
        putStrLn "Waiting"
        return output

main :: IO ()
main = do
  _ <- getFileContent
  return ()