Skip to content

Commit

Permalink
Disable buffering for Haskell
Browse files Browse the repository at this point in the history
  • Loading branch information
andy1li committed Nov 5, 2024
1 parent 265e5ae commit 0175a73
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
6 changes: 5 additions & 1 deletion compiled_starters/haskell/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
module Main (main) where

import Network.Simple.TCP (serve, HostPreference(HostAny), closeSock)

import System.IO (hSetBuffering, stdout, stderr, BufferMode(NoBuffering))

main :: IO ()
main = do
-- Disable output buffering
hSetBuffering stdout NoBuffering
hSetBuffering stderr NoBuffering

-- You can use print statements as follows for debugging, they'll be visible when running tests.
putStrLn "Logs from your program will appear here"

Expand Down
6 changes: 5 additions & 1 deletion solutions/haskell/01-jm1/code/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
module Main (main) where

import Network.Simple.TCP (serve, HostPreference(HostAny), closeSock)

import System.IO (hSetBuffering, stdout, stderr, BufferMode(NoBuffering))

main :: IO ()
main = do
-- Disable output buffering
hSetBuffering stdout NoBuffering
hSetBuffering stderr NoBuffering

let port = "6379"
putStrLn $ "Redis server listening on port " ++ port
serve HostAny port $ \(socket, address) -> do
Expand Down
8 changes: 6 additions & 2 deletions solutions/haskell/01-jm1/diff/app/Main.hs.diff
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
@@ -1,20 +1,16 @@
@@ -1,24 +1,20 @@
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE OverloadedStrings #-}

module Main (main) where

import Network.Simple.TCP (serve, HostPreference(HostAny), closeSock)

import System.IO (hSetBuffering, stdout, stderr, BufferMode(NoBuffering))

main :: IO ()
main = do
-- Disable output buffering
hSetBuffering stdout NoBuffering
hSetBuffering stderr NoBuffering

- -- You can use print statements as follows for debugging, they'll be visible when running tests.
- putStrLn "Logs from your program will appear here"
-
Expand Down
6 changes: 5 additions & 1 deletion starter_templates/haskell/code/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
module Main (main) where

import Network.Simple.TCP (serve, HostPreference(HostAny), closeSock)

import System.IO (hSetBuffering, stdout, stderr, BufferMode(NoBuffering))

main :: IO ()
main = do
-- Disable output buffering
hSetBuffering stdout NoBuffering
hSetBuffering stderr NoBuffering

-- You can use print statements as follows for debugging, they'll be visible when running tests.
putStrLn "Logs from your program will appear here"

Expand Down

0 comments on commit 0175a73

Please sign in to comment.