Skip to content

Instantly share code, notes, and snippets.

@fishyFrogFace
Last active April 14, 2019 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fishyFrogFace/95c4cbe4aab535cfa48c2280223cf9c1 to your computer and use it in GitHub Desktop.
Save fishyFrogFace/95c4cbe4aab535cfa48c2280223cf9c1 to your computer and use it in GitHub Desktop.
Read from file
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