Skip to content

Commit

Permalink
Merge pull request #272 from codecrafters-io/disable-buffering-for-ha…
Browse files Browse the repository at this point in the history
…skell

CC-1491: Disable stderr/out buffering for Haskell starter code
  • Loading branch information
andy1li authored Nov 5, 2024
2 parents 265e5ae + 0175a73 commit a17da1d
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 a17da1d

Please sign in to comment.