Skip to content

Instantly share code, notes, and snippets.

@vaibhavsagar
Created October 5, 2017 00:19
Show Gist options
  • Save vaibhavsagar/688dc28349d3eb85cd51449decd75722 to your computer and use it in GitHub Desktop.
Save vaibhavsagar/688dc28349d3eb85cd51449decd75722 to your computer and use it in GitHub Desktop.
Fun with (.).(.)
module Owl where
import System.FilePath ((</>))
fromMaybe :: a -> Maybe a -> a
fromMaybe a m = case m of
Nothing -> a
Just b -> b
prependPath :: FilePath -> FilePath -> FilePath
prependPath dir base = dir </> base
makePath'', makePath', makePath :: FilePath -> FilePath -> Maybe FilePath -> FilePath
makePath'' dir def maybeValue = prependPath dir $ fromMaybe def maybeValue
makePath' dir def = prependPath dir . fromMaybe def
(.:) :: (b -> c) -> (d -> a -> b) -> d -> a -> c
(.:) = (.) . (.)
makePath base = prependPath base .: fromMaybe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment