Logo

Programming-Idioms

  • Haskell

Idiom #106 Get program working directory

Assign to string dir the path of the working directory.
(This is not necessarily the folder containing the executable itself)

import System.Directory
dir <- getCurrentDirectory

Note: The dir may only be used in a do-block. Specifically, this syntax (<-) is do-block exclusive.
To use elsewhere, use getCurrentDirectory (with caution!)
with Ada.Directories; use Ada.Directories;
Dir : String := Current_Directory;

New implementation...
< >
programming-idioms.org