Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

determine the name of the executing script

Tags:

haskell

In haskell how would I go about getting and printing out the name of the executing script? Also since I'm here when I use some code to list directory contents and print them out at the console (GHCi) I just get the following result "[]" from my knowledge of other languages i would assume it's because it returns an array but then print should print the array anyway, no?

this is on windows

like image 732
ace007 Avatar asked Jan 31 '26 18:01

ace007


2 Answers

I think getProgName from System.Environment should do that but you should check how portable it is on windows.

"[]" is the empty list. You can use getDirectoryContents from System.Directory.

Prelude System.Directory> getDirectoryContents "."
["hist","parse.hs","b.hs","d.hs","qsort.hs"]
like image 165
Satvik Avatar answered Feb 02 '26 14:02

Satvik


The System.Environment module is used to access information about the system environment, such as getProgName which returns the name of the executable.

The result [] is an empty list, so it seems you are trying to list the contents of an empty directory.

like image 41
shang Avatar answered Feb 02 '26 13:02

shang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!