------------------------------------------------------------------------------
-- | Locates the 'lessc' executable.
findLessc :: IO FilePath
findLessc = do
    findExecutable "lessc" >>= maybe (findM exec gems) (return . Just) >>=
        maybe (error "Could not find executable `lessc'") return
  where
    gems    = ["/var/lib/gems/1.9.1/bin/lessc", "/var/lib/gems/1.8/bin/lessc"]
    findM p = fmap listToMaybe . filterM p
    exec f  = do
        exists <- doesFileExist f
        if exists then getPermissions f >>= return . executable
                  else return False


------------------------------------------------------------------------------
-- | Given the path to a @.less@ file, this returns its contents processed by
-- @lessc@.
findLessc :: IO FilePath
findLessc = do
    findExecutable "lessc" >>= maybe (findM exec gems) (return . Just) >>=
        maybe (error "Could not find executable `lessc'") return
  where
    gems    = ["/var/lib/gems/1.9.1/bin/lessc", "/var/lib/gems/1.8/bin/lessc"]
    findM p = fmap listToMaybe . filterM p
    exec f  = do
        exists <- doesFileExist f
        if exists then getPermissions f >>= return . executable
                  else return False


------------------------------------------------------------------------------
-- | Given the path to a @.less@ file, this returns its contents processed by
-- @lessc@.
findLessc = do
    findExecutable "lessc" >>= maybe (findM exec gems) (return . Just) >>=
        maybe (error "Could not find executable `lessc'") return
  where
    gems    = ["/var/lib/gems/1.9.1/bin/lessc", "/var/lib/gems/1.8/bin/lessc"]
    findM p = fmap listToMaybe . filterM p
    exec f  = do
        exists <- doesFileExist f
        if exists then getPermissions f >>= return . executable
                  else return False


------------------------------------------------------------------------------
-- | Given the path to a @.less@ file, this returns its contents processed by
-- @lessc@.