Last active
April 14, 2019 12:03
-
-
Save fishyFrogFace/95c4cbe4aab535cfa48c2280223cf9c1 to your computer and use it in GitHub Desktop.
Read from file
This file contains 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 System.Environment (getArgs) | |
doStuffToFile :: String -> IO () | |
doStuffToFile str = print $ length str | |
-- alt1: "stack build" så "stack exec <projectname>-exe path-to-file-if-not-in-folder/bible.txt" | |
main :: IO () | |
main = do | |
args <- getArgs | |
case args of | |
[filepath] -> readFile filepath >>= doStuffToFile | |
_ -> putStrLn "Provide a filename, u idiot" | |
-- alt2: "stack ghci" så "main" | |
main2 :: IO () | |
main2 = do | |
bib <- readFile "bible.txt" | |
putStrLn bib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment