Skip to content

Instantly share code, notes, and snippets.

@danidiaz
Created November 24, 2013 16:58
Show Gist options
  • Select an option

  • Save danidiaz/7629418 to your computer and use it in GitHub Desktop.

Select an option

Save danidiaz/7629418 to your computer and use it in GitHub Desktop.
concatenative obscurity
import System.Directory
import System.FilePath
import Control.Monad.List
import Control.Arrow
import Control.Applicative
import Control.Lens
import Data.Function
import Data.Monoid
cleave :: (a -> b) -> (a -> c) -> (b -> c -> d) -> a -> d
cleave h i f = liftA2 f h i
fam = fst &&& (\(path,time) -> replaceBaseName path $ takeBaseName path ++ time)
fim = fst &&& liftA2 replaceBaseName fst (liftA2 (++) (takeBaseName.fst) snd) -- ugliest
fum = fst &&& uncurry (cleave replaceBaseName ((++) . takeBaseName) (.))
fem = fst &&& uncurry (liftA2 (.) replaceBaseName ((++) . takeBaseName))
fom = fst &&& uncurry (liftA2 liftA replaceBaseName ((++) . takeBaseName))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment