Skip to content

Instantly share code, notes, and snippets.

@Javran
Created November 19, 2013 02:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Javran/7539031 to your computer and use it in GitHub Desktop.
Save Javran/7539031 to your computer and use it in GitHub Desktop.
Haskell from Scratch #5
import Control.Monad
import System.FilePath
import System.Directory
import Data.Maybe
redoPath :: FilePath -> IO (Maybe FilePath)
redoPath target = listToMaybe `liftM` filterM doesFileExist candidates
where candidates = map (++ ".do") $ target : fallbacks
fallbacks = map (`replaceBaseName` "default") $ filter hasExtension [target]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment