Skip to content

Instantly share code, notes, and snippets.

View baharev's full-sized avatar

Ali Baharev baharev

View GitHub Profile
data Lit = Lit Int
data Add l r = Add l r
class Eval x where
eval :: x -> Int
instance Eval Lit where
eval (Lit x) = x
instance (Eval l, Eval r) => Eval (Add l r) where
@Javran
Javran / gist:7539031
Created November 19, 2013 02:04
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]