Skip to content

Instantly share code, notes, and snippets.

Avatar

Ali Baharev baharev

View GitHub Profile
View Main.hs
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 Nov 19, 2013
Haskell from Scratch #5
View gist:7539031
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]