Fix compatibility with GHC 7.2.

This commit is contained in:
Paolo Capriotti 2012-12-23 20:43:49 +00:00
parent cc14cdf180
commit 5f3ae68ea8
3 changed files with 26 additions and 16 deletions

View File

@ -23,11 +23,12 @@ bashCompletionParser parser pprefs = complParser
complParser = asum
[ failure <$>
( bashCompletionQuery parser pprefs
<$> (many . strOption) (long "bash-completion-word" <> internal)
<*> option (long "bash-completion-index" <> internal) )
<$> (many . strOption) (long "bash-completion-word"
`mappend` internal)
<*> option (long "bash-completion-index" `mappend` internal) )
, failure <$>
(bashCompletionScript <$>
strOption (long "bash-completion-script" <> internal)) ]
strOption (long "bash-completion-script" `mappend` internal)) ]
bashCompletionQuery :: Parser a -> ParserPrefs -> [String] -> Int -> String -> IO [String]
bashCompletionQuery parser pprefs ws i _ = case runCompletion compl pprefs of

View File

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
module Options.Applicative.Builder (
-- * Parser builders
--
@ -47,7 +48,10 @@ module Options.Applicative.Builder (
completer,
idm,
(&),
#if __GLASGOW_HASKELL__ > 702
(<>),
#endif
mappend,
-- * Readers
--
@ -76,7 +80,11 @@ module Options.Applicative.Builder (
) where
import Control.Applicative (pure, (<|>))
import Data.Monoid (Monoid (..), (<>))
import Data.Monoid (Monoid (..)
#if __GLASGOW_HASKELL__ > 702
, (<>)
#endif
)
import Options.Applicative.Builder.Completer
import Options.Applicative.Builder.Arguments
@ -173,7 +181,7 @@ completer f = fieldMod $ modCompleter (`mappend` f)
subparser :: Mod CommandFields a -> Parser a
subparser m = mkParser d g rdr
where
Mod f d g = m <> metavar "COMMAND"
Mod f d g = m `mappend` metavar "COMMAND"
CommandFields cmds = f (CommandFields [])
rdr = CmdReader (map fst cmds) (`lookup` cmds)
-- | Builder for a flag parser.
@ -223,11 +231,11 @@ nullOption m = mkParser d g rdr
-- | Builder for an option taking a 'String' argument.
strOption :: Mod OptionFields String -> Parser String
strOption m = nullOption $ reader str <> m
strOption m = nullOption $ reader str `mappend` m
-- | Builder for an option using the 'auto' reader.
option :: Read a => Mod OptionFields a -> Parser a
option m = nullOption $ reader auto <> m
option m = nullOption $ reader auto `mappend` m
-- | Modifier for 'ParserInfo'.
newtype InfoMod a = InfoMod

View File

@ -12,6 +12,7 @@ module Options.Applicative.Extra (
) where
import Control.Applicative ((<$>), (<|>))
import Data.Monoid (mconcat)
import System.Environment (getArgs, getProgName)
import System.Exit (exitWith, ExitCode(..))
import System.IO (hPutStr, stderr)
@ -26,15 +27,15 @@ import Options.Applicative.Types
-- | A hidden \"helper\" option which always fails.
helper :: Parser (a -> a)
helper = nullOption
( long "help"
<> reader (const (Left ShowHelpText))
<> noArgError ShowHelpText
<> short 'h'
<> help "Show this help text"
<> value id
<> metavar ""
<> hidden )
helper = nullOption $ mconcat
[ long "help"
, reader (const (Left ShowHelpText))
, noArgError ShowHelpText
, short 'h'
, help "Show this help text"
, value id
, metavar ""
, hidden ]
-- | Run a program description.
--