Optparse GHC 7.4 compatibility

This commit is contained in:
Nikolay Yakimov 2015-12-06 01:32:09 +03:00
parent b2fb54a356
commit 9fd738ec97
3 changed files with 19 additions and 6 deletions

View File

@ -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

View File

@ -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

View 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