diff options
author | Joey Hess <joey@kitenet.net> | 2011-08-25 00:28:55 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-08-25 01:27:19 -0400 |
commit | 678726c10c13481c082743808a5188d28567e2b3 (patch) | |
tree | a5052eb5b20444e10d3f5d467281ef4c0f5975d1 /Utility | |
parent | 20259c2955e408a72e0960207fc8be4cbeec2e21 (diff) |
code simplification thanks to applicative functors
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Path.hs | 4 | ||||
-rw-r--r-- | Utility/Url.hs | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/Utility/Path.hs b/Utility/Path.hs index 517c175bc..9b8041dad 100644 --- a/Utility/Path.hs +++ b/Utility/Path.hs @@ -13,7 +13,7 @@ import System.FilePath import System.Directory import Data.List import Data.Maybe -import Control.Monad (liftM2) +import Control.Applicative {- Returns the parent directory of a path. Parent of / is "" -} parentDir :: FilePath -> FilePath @@ -65,7 +65,7 @@ absPathFrom cwd file = fromMaybe bad $ absNormPath cwd file - relPathCwdToFile "/tmp/foo/bar" == "" -} relPathCwdToFile :: FilePath -> IO FilePath -relPathCwdToFile f = liftM2 relPathDirToFile getCurrentDirectory (absPath f) +relPathCwdToFile f = relPathDirToFile <$> getCurrentDirectory <*> absPath f {- Constructs a relative path from a directory to a file. - diff --git a/Utility/Url.hs b/Utility/Url.hs index 69b53c34c..f678720ed 100644 --- a/Utility/Url.hs +++ b/Utility/Url.hs @@ -11,7 +11,7 @@ module Utility.Url ( get ) where -import Control.Monad (liftM) +import Control.Applicative import Control.Monad.State (liftIO) import qualified Network.Browser as Browser import Network.HTTP @@ -64,7 +64,6 @@ request url requesttype = Browser.browse $ do Browser.setErrHandler ignore Browser.setOutHandler ignore Browser.setAllowRedirects True - liftM snd $ Browser.request - (mkRequest requesttype url :: Request_String) + snd <$> Browser.request (mkRequest requesttype url :: Request_String) where ignore = const $ return () |