path - How to determine the directory in which a running Haskell script or application lives? -


i have haskell script runs via shebang line making use of runhaskell utility. e.g...

#! /usr/bin/env runhaskell module main main = { ... } 

now, i'd able determine directory in script resides from within script, itself. so, if script lives in /home/me/my-haskell-app/script.hs, should able run anywhere, using relative or absolute path, , should know it's located in /home/me/my-haskell-app/ directory.

i thought functionality available in system.environment module might able help, fell little short. getprogname did not seem provide useful file-path information. found environment variable _ (that's underscore) sometimes contain path script, invoked; however, script invoked via other program or parent script, environment variable seems lose value (and needing invoke haskell script another, parent application).

also useful-to-know whether can determine directory in pre-compiled haskell executable lives, using same technique or otherwise.

there findbin package seems suit needs , works compiled programs.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -