Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create symlink with Haskell?

How to create a symlink with Haskell? The directory package to my knowledge does not provide a way to do it.

like image 304
Mark Karpov Avatar asked May 11 '16 05:05

Mark Karpov


1 Answers

Creating a symbolic link is non-portable. For example, the creation symbolic links on Windows is re­strict­ed1. Therefore it does not fit into directory providing "a basic set of operations for ma­nip­u­lat­ing files and directories in a portable way" (emphasis mine). This affects all platform independent packages.

The platform specific package unix provides that functionality in System.Posix.Files with createSymbolicLink though:

import System.Posix.Files (createSymbolicLink)

main :: IO ()
main = createSymbolicLink "/opt/ghc/7.10.3" "/opt/ghc/active"

1: That's also a reason why unix-compat does not implement createSymbolicLink

like image 153
Zeta Avatar answered Oct 05 '22 13:10

Zeta