Created
February 23, 2017 12:40
-
-
Save nurpax/93d4f4386f0ee58234c788f32b5b39e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Maybe | |
import System.IO (readFile) | |
-- Open a file and process its contents with action, or return the default value 'deflt' | |
maybeWithFile :: Maybe FilePath -> b -> (String -> b) -> IO b | |
maybeWithFile fname deflt action = maybe (return deflt) (fmap action . readFile) fname | |
main :: IO () | |
main = do | |
let inactiveWhitelist = Just "whitelist.txt" | |
whitelist <- maybeWithFile inactiveWhitelist [] $ \contents -> words contents | |
print whitelist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment