summaryrefslogtreecommitdiff
path: root/2020/Input.hs
blob: afce44e4421f064622bf48387c0def3572185f4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Input where

import System.Environment
import System.IO


getInput :: Int -> IO [String]
getInput day = do
    let fname = show day ++ ".in"

    args <- getArgs
    str <- case args of
        ["-"] -> getContents
        [] -> readFile fname
        _ -> do
            hPutStrLn stderr $ "WARNING: Unrecognised command-line parameters " ++ show args ++
                               ", reading from " ++ fname
            readFile fname

    return (lines str)