From 7f7249f801653e0bd7fa083ed001bf3c5a3c3900 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 16 Oct 2015 15:31:18 -0400 Subject: add a LinkTarget type to disambiguate parameters of isSymlinkedTo Something about making symlinks is very confusing about which parameter is which. It perhaps doesn't help that isSymlinkedTo has the target second, while ln has it first. Let's use a type to prevent confusion. Also, simplified some properties that now use isSymlinkedTo. Since isSymlinkedTo checks the link target, these properties don't need to check themselves that the link is in place. --- src/Propellor/Property/File.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Propellor/Property/File.hs') diff --git a/src/Propellor/Property/File.hs b/src/Propellor/Property/File.hs index 07ace24b..08fdc780 100644 --- a/src/Propellor/Property/File.hs +++ b/src/Propellor/Property/File.hs @@ -97,14 +97,14 @@ dirExists :: FilePath -> Property NoInfo dirExists d = check (not <$> doesDirectoryExist d) $ property (d ++ " exists") $ makeChange $ createDirectoryIfMissing True d +-- | The location that a symbolic link points to. +newtype LinkTarget = LinkTarget FilePath + -- | Creates or atomically updates a symbolic link. -- --- The first parameter is what the link should point to. --- --- The second parameter is the name of the symbolic link to create. -- Does not overwrite regular files or directories. -isSymlinkedTo :: FilePath -> FilePath -> Property NoInfo -link `isSymlinkedTo` target = property desc $ +isSymlinkedTo :: FilePath -> LinkTarget -> Property NoInfo +link `isSymlinkedTo` (LinkTarget target) = property desc $ go =<< (liftIO $ tryIO $ getSymbolicLinkStatus link) where desc = link ++ " is symlinked to " ++ target -- cgit v1.2.3