diff --git a/ghc-mod.cabal b/ghc-mod.cabal index ab5fe1a..ded363f 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -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 diff --git a/src/GHCMod/Options/Commands.hs b/src/GHCMod/Options/Commands.hs index e5824c3..e824d37 100644 --- a/src/GHCMod/Options/Commands.hs +++ b/src/GHCMod/Options/Commands.hs @@ -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 diff --git a/src/GHCMod/Options/GapUtils.hs b/src/GHCMod/Options/GapUtils.hs new file mode 100644 index 0000000..7062892 --- /dev/null +++ b/src/GHCMod/Options/GapUtils.hs @@ -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