Skip to content

Commit 0c14fa5

Browse files
committed
fix getClientConfigAction
1 parent 25a614f commit 0c14fa5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ module Development.IDE.Core.Rules(
6262

6363
import Fingerprint
6464

65-
import Data.Aeson (fromJSON,toJSON, Result(Success), FromJSON)
65+
import Data.Aeson (toJSON, Result(Success))
6666
import Data.Binary hiding (get, put)
67-
import Data.Default
6867
import Data.Tuple.Extra
6968
import Control.Monad.Extra
7069
import Control.Monad.Trans.Class
@@ -136,6 +135,8 @@ import GHC.IO.Encoding
136135
import Data.ByteString.Encoding as T
137136

138137
import qualified HieDb
138+
import Ide.Plugin.Config
139+
import qualified Data.Aeson.Types as A
139140

140141
-- | This is useful for rules to convert rules that can only produce errors or
141142
-- a result into the more general IdeResult type that supports producing
@@ -1047,12 +1048,13 @@ getClientSettingsRule = defineEarlyCutOffNoFile $ \GetClientSettings -> do
10471048

10481049
-- | Returns the client configurarion stored in the IdeState.
10491050
-- You can use this function to access it from shake Rules
1050-
getClientConfigAction :: (Default a, FromJSON a) => Action a
1051-
getClientConfigAction = do
1051+
getClientConfigAction :: Config -- ^ default value
1052+
-> Action Config
1053+
getClientConfigAction defValue = do
10521054
mbVal <- unhashed <$> useNoFile_ GetClientSettings
1053-
case fromJSON <$> mbVal of
1055+
case A.parse (parseConfig defValue) <$> mbVal of
10541056
Just (Success c) -> return c
1055-
_ -> return def
1057+
_ -> return defValue
10561058

10571059
-- | For now we always use bytecode
10581060
getLinkableType :: NormalizedFilePath -> Action (Maybe LinkableType)

0 commit comments

Comments
 (0)