Optparse GHC 7.4 compatibility
This commit is contained in:
parent
b2fb54a356
commit
9fd738ec97
@ -192,6 +192,7 @@ Executable ghc-mod
|
||||
, GHCMod.Options.Commands
|
||||
, GHCMod.Version
|
||||
, GHCMod.Options.DocUtils
|
||||
, GHCMod.Options.GapUtils
|
||||
GHC-Options: -Wall -fno-warn-deprecations -threaded
|
||||
Default-Extensions: ConstraintKinds, FlexibleContexts
|
||||
HS-Source-Dirs: src
|
||||
|
@ -3,8 +3,8 @@ module GHCMod.Options.Commands where
|
||||
import Options.Applicative
|
||||
import Options.Applicative.Types
|
||||
import Language.Haskell.GhcMod.Types
|
||||
import Text.Read (readMaybe)
|
||||
import GHCMod.Options.DocUtils
|
||||
import GHCMod.Options.GapUtils
|
||||
|
||||
type Symbol = String
|
||||
type Expr = String
|
||||
@ -37,11 +37,6 @@ data GhcModCommands =
|
||||
| CmdAuto FilePath Point
|
||||
| CmdRefine FilePath Point Expr
|
||||
|
||||
int :: ReadM Int
|
||||
int = do
|
||||
v <- readerAsk
|
||||
maybe (readerError $ "Not a number \"" ++ v ++ "\"") return $ readMaybe v
|
||||
|
||||
commandsSpec :: Parser GhcModCommands
|
||||
commandsSpec =
|
||||
hsubparser (
|
||||
@ -228,3 +223,8 @@ autoArgSpec = locArgSpec CmdAuto
|
||||
splitArgSpec = locArgSpec CmdSplit
|
||||
sigArgSpec = locArgSpec CmdSig
|
||||
refineArgSpec = locArgSpec CmdRefine <*> strArg "SYMBOL"
|
||||
|
||||
int :: ReadM Int
|
||||
int = do
|
||||
v <- readerAsk
|
||||
maybe (readerError $ "Not a number \"" ++ v ++ "\"") return $ readMaybe v
|
||||
|
12
src/GHCMod/Options/GapUtils.hs
Normal file
12
src/GHCMod/Options/GapUtils.hs
Normal file
@ -0,0 +1,12 @@
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
module GHCMod.Options.GapUtils (
|
||||
readMaybe
|
||||
) where
|
||||
|
||||
#if __GLASGOW_HASKELL__ >= 706
|
||||
import Text.Read (readMaybe)
|
||||
#else
|
||||
readMaybe :: Read a => String -> Maybe a
|
||||
readMaybe = Just . read
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user