<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
</head>
<body style="font-family:Arial;font-size:14px">
<p>Hello Awsaf, <br>
<br>
you should probably look further into the topic of "IO in Haskell" and "Monads". Then you can use impure functions like readFile (<a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/Prelude.html#v:readFile" name="readFile">http://hackage.haskell.org/package/base-4.11.1.0/docs/Prelude.html#v:readFile</a> ) or getArgs (<a href="http://hackage.haskell.org/package/base-4.11.1.0/docs/System-Environment.html#v:getArgs">http://hackage.haskell.org/package/base-4.11.1.0/docs/System-Environment.html#v:getArgs</a>). A naive solution might look like this: <br>
</p>
<div>module Main where</div>
<div> </div>
<div>import System.Environment (getArgs)</div>
<div> </div>
<div>main = do</div>
<div> (fileName:_) <- getArgs</div>
<div> unsortedList <- read <$> readFile fileName</div>
<div> let sorted = yourMergeSortFunction unsortedList</div>
<div> print sorted -- maybe you like to print your sorted list<br>
<br>
<br>
Best regards,<br>
Tobias</div>
<p><br>
<br>
----- Nachricht von Awsaf Rahman <<a href="mailto:awsafrahman1704@gmail.com">awsafrahman1704@gmail.com</a>> ---------<br>
Datum: Thu, 5 Jul 2018 22:21:15 +0200<br>
Von: Awsaf Rahman <<a href="mailto:awsafrahman1704@gmail.com">awsafrahman1704@gmail.com</a>><br>
Antwort an: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>><br>
Betreff: [Haskell-beginners] Passing a file containing a list as an input<br>
An: <a href="mailto:beginners@haskell.org">beginners@haskell.org</a></p>
<blockquote style="border-left:2px solid blue;margin-left:2px;padding-left:12px;" type="cite">
<div dir="ltr">Hello everyone!
<div> </div>
<div>I am really struggling with Haskell I/O. </div>
<div> </div>
<div>I have written a mergesort program and as an input to that program I want to use a file containing a list of 1000 integers. Let's say the contents of the file look like this</div>
<div> </div>
<div>[120, 400, 500 , 20, 100 ..] </div>
<div> </div>
<div>How can I achieve that? I am trying to write a main function that takes the file as an input and passes the list to my mergesort function.. </div>
<div> </div>
<div>Regards</div>
<div>Awsaf Rahman</div>
</div>
</blockquote>
<p><br>
<br>
<br>
----- Ende der Nachricht von Awsaf Rahman <<a href="mailto:awsafrahman1704@gmail.com">awsafrahman1704@gmail.com</a>> -----<br>
<br></p>
</body>
</html>