From c3722f7a20419c6f5c19166773008aa5f3222823 Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Thu, 17 Jul 2014 06:59:10 +0200 Subject: [PATCH] Include 'refine' again --- Language/Haskell/GhcMod.hs | 1 + Language/Haskell/GhcMod/FillSig.hs | 4 +++- src/GHCMod.hs | 2 +- src/GHCModi.hs | 11 +++++------ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Language/Haskell/GhcMod.hs b/Language/Haskell/GhcMod.hs index 01c0e04..dce08ca 100644 --- a/Language/Haskell/GhcMod.hs +++ b/Language/Haskell/GhcMod.hs @@ -28,6 +28,7 @@ module Language.Haskell.GhcMod ( , types , splits , sig + , refine , modules , languages , flags diff --git a/Language/Haskell/GhcMod/FillSig.hs b/Language/Haskell/GhcMod/FillSig.hs index 2fcc543..1b2cb68 100644 --- a/Language/Haskell/GhcMod/FillSig.hs +++ b/Language/Haskell/GhcMod/FillSig.hs @@ -2,6 +2,7 @@ module Language.Haskell.GhcMod.FillSig ( sig + , refine ) where import Data.Char (isSymbol) @@ -181,13 +182,14 @@ isSymbolName [] = error "This should never happen" -- REWRITE A HOLE / UNDEFINED VIA A FUNCTION ---------------------------------------------------------------- -{- refine :: IOish m => FilePath -- ^ A target file. -> Int -- ^ Line number. -> Int -- ^ Column number. -> Expression -- ^ A Haskell expression. -> GhcModT m String +refine file lineNo colNo expr = undefined +{- refine file lineNo colNo expr = ghandle handler body where body = inModuleContext file $ \dflag style -> do diff --git a/src/GHCMod.hs b/src/GHCMod.hs index 6629d05..6de9125 100644 --- a/src/GHCMod.hs +++ b/src/GHCMod.hs @@ -125,7 +125,7 @@ main = flip E.catches handlers $ do "type" -> nArgs 4 $ types cmdArg1 (read cmdArg3) (read cmdArg4) "split" -> nArgs 4 $ splits cmdArg1 (read cmdArg3) (read cmdArg4) "sig" -> nArgs 4 $ sig cmdArg1 (read cmdArg3) (read cmdArg4) - --"refine" -> nArgs 5 $ refine cmdArg1 (read cmdArg3) (read cmdArg4) cmdArg5 + "refine" -> nArgs 5 $ refine cmdArg1 (read cmdArg3) (read cmdArg4) cmdArg5 "find" -> nArgs 1 $ findSymbol cmdArg1 "lint" -> nArgs 1 $ withFile lint cmdArg1 "root" -> rootInfo diff --git a/src/GHCModi.hs b/src/GHCModi.hs index 5fd17ac..1b074ad 100644 --- a/src/GHCModi.hs +++ b/src/GHCModi.hs @@ -137,7 +137,7 @@ loop set mvar = do "type" -> showType set arg "split" -> doSplit set arg "sig" -> doSig set arg - -- "refine" -> doRefine set arg + "refine" -> doRefine set arg "boot" -> bootIt set "browse" -> browseIt set arg "quit" -> return ("quit", False, set) @@ -270,16 +270,15 @@ doSig set fileArg = do ret <- sig file (read line) (read column) return (ret, True, set') -{- -doRefine :: Set FilePath +doRefine :: IOish m + => Set FilePath -> FilePath - -> GhcMod (String, Bool, Set FilePath) + -> GhcModT m (String, Bool, Set FilePath) doRefine set fileArg = do let [file, line, column, expr] = words fileArg set' <- newFileSet set file - ret <- rewrite file (read line) (read column) expr + ret <- refine file (read line) (read column) expr return (ret, True, set') --} ----------------------------------------------------------------