Skip to content

Commit

Permalink
Merge pull request #106 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 d0f7bab + 6587e32 commit b66287a
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 67 deletions.
5 changes: 5 additions & 0 deletions compiled_starters/haskell/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Main where

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

matchPattern :: String -> String -> Bool
matchPattern pattern input = do
Expand All @@ -11,6 +12,10 @@ matchPattern pattern input = do

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

args <- getArgs
let pattern = args !! 1
input_line <- getLine
Expand Down
44 changes: 22 additions & 22 deletions compiled_starters/haskell/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@
#
# DON'T EDIT THIS!

name: hs-grep-clone
version: 0.1.0.0
license: BSD3
name: hs-grep-clone
version: 0.1.0.0
license: BSD3

dependencies:
- base >= 4.7 && < 5
- megaparsec # can help when implementing the parser
- parser-combinators # extends megaparsec
- containers # Set, Map, Seq
- unordered-containers # HashSet, HashMap
- hashable # when using your own data types with unordered-containers
- mtl # monad transformers to help with nested monads
- base >= 4.7 && < 5
- megaparsec # can help when implementing the parser
- parser-combinators # extends megaparsec
- containers # Set, Map, Seq
- unordered-containers # HashSet, HashMap
- hashable # when using your own data types with unordered-containers
- mtl # monad transformers to help with nested monads

default-extensions:
- BlockArguments
- ImportQualifiedPost
- LambdaCase
- NamedFieldPuns
- RecordWildCards
- BlockArguments
- ImportQualifiedPost
- LambdaCase
- NamedFieldPuns
- RecordWildCards

library:
source-dirs: src
source-dirs: app

executables:
hs-grep-clone-exe:
main: Main.hs
source-dirs: app
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- hs-grep-clone
- hs-grep-clone
5 changes: 5 additions & 0 deletions solutions/haskell/01-cq2/code/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Main where

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

matchPattern :: String -> String -> Bool
matchPattern pattern input = do
Expand All @@ -11,6 +12,10 @@ matchPattern pattern input = do

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

args <- getArgs
let pattern = args !! 1
input_line <- getLine
Expand Down
44 changes: 22 additions & 22 deletions solutions/haskell/01-cq2/code/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@
#
# DON'T EDIT THIS!

name: hs-grep-clone
version: 0.1.0.0
license: BSD3
name: hs-grep-clone
version: 0.1.0.0
license: BSD3

dependencies:
- base >= 4.7 && < 5
- megaparsec # can help when implementing the parser
- parser-combinators # extends megaparsec
- containers # Set, Map, Seq
- unordered-containers # HashSet, HashMap
- hashable # when using your own data types with unordered-containers
- mtl # monad transformers to help with nested monads
- base >= 4.7 && < 5
- megaparsec # can help when implementing the parser
- parser-combinators # extends megaparsec
- containers # Set, Map, Seq
- unordered-containers # HashSet, HashMap
- hashable # when using your own data types with unordered-containers
- mtl # monad transformers to help with nested monads

default-extensions:
- BlockArguments
- ImportQualifiedPost
- LambdaCase
- NamedFieldPuns
- RecordWildCards
- BlockArguments
- ImportQualifiedPost
- LambdaCase
- NamedFieldPuns
- RecordWildCards

library:
source-dirs: src
source-dirs: app

executables:
hs-grep-clone-exe:
main: Main.hs
source-dirs: app
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- hs-grep-clone
- hs-grep-clone
7 changes: 6 additions & 1 deletion solutions/haskell/01-cq2/diff/app/Main.hs.diff
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
@@ -1,28 +1,24 @@
@@ -1,33 +1,29 @@
module Main where

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

matchPattern :: String -> String -> Bool
matchPattern pattern input = do
Expand All @@ -12,6 +13,10 @@

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

args <- getArgs
let pattern = args !! 1
input_line <- getLine
Expand Down
5 changes: 5 additions & 0 deletions starter_templates/haskell/code/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Main where

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

matchPattern :: String -> String -> Bool
matchPattern pattern input = do
Expand All @@ -11,6 +12,10 @@ matchPattern pattern input = do

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

args <- getArgs
let pattern = args !! 1
input_line <- getLine
Expand Down
44 changes: 22 additions & 22 deletions starter_templates/haskell/code/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@
#
# DON'T EDIT THIS!

name: hs-grep-clone
version: 0.1.0.0
license: BSD3
name: hs-grep-clone
version: 0.1.0.0
license: BSD3

dependencies:
- base >= 4.7 && < 5
- megaparsec # can help when implementing the parser
- parser-combinators # extends megaparsec
- containers # Set, Map, Seq
- unordered-containers # HashSet, HashMap
- hashable # when using your own data types with unordered-containers
- mtl # monad transformers to help with nested monads
- base >= 4.7 && < 5
- megaparsec # can help when implementing the parser
- parser-combinators # extends megaparsec
- containers # Set, Map, Seq
- unordered-containers # HashSet, HashMap
- hashable # when using your own data types with unordered-containers
- mtl # monad transformers to help with nested monads

default-extensions:
- BlockArguments
- ImportQualifiedPost
- LambdaCase
- NamedFieldPuns
- RecordWildCards
- BlockArguments
- ImportQualifiedPost
- LambdaCase
- NamedFieldPuns
- RecordWildCards

library:
source-dirs: src
source-dirs: app

executables:
hs-grep-clone-exe:
main: Main.hs
source-dirs: app
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- hs-grep-clone
- hs-grep-clone

0 comments on commit b66287a

Please sign in to comment.