Skip to content

Commit c5aed6e

Browse files
committed
Add a notice that "stack query global-hints" is experimental #3796
1 parent 5131361 commit c5aed6e

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/Stack/Build.hs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Stack.Build
2424
import Stack.Prelude
2525
import Data.Aeson (Value (Object, Array), (.=), object)
2626
import qualified Data.HashMap.Strict as HM
27-
import Data.List ((\\))
27+
import Data.List ((\\), isPrefixOf)
2828
import Data.List.Extra (groupSort)
2929
import Data.List.NonEmpty (NonEmpty(..))
3030
import qualified Data.List.NonEmpty as NE
@@ -347,7 +347,7 @@ queryBuildInfo :: HasEnvConfig env
347347
queryBuildInfo selectors0 =
348348
rawBuildInfo
349349
>>= select id selectors0
350-
>>= liftIO . TIO.putStrLn . decodeUtf8 . Yaml.encode
350+
>>= liftIO . TIO.putStrLn . addGlobalHintsComment . decodeUtf8 . Yaml.encode
351351
where
352352
select _ [] value = return value
353353
select front (sel:sels) value =
@@ -366,7 +366,21 @@ queryBuildInfo selectors0 =
366366
where
367367
cont = select (front . (sel:)) sels
368368
err msg = throwString $ msg ++ ": " ++ show (front [sel])
369-
369+
-- Include comments to indicate that this portion of the "stack
370+
-- query" API is not necessarily stable.
371+
addGlobalHintsComment
372+
| null selectors0 = T.replace globalHintsLine ("\n" <> globalHintsComment <> globalHintsLine)
373+
-- Append comment instead of pre-pending. The reasoning here is
374+
-- that something *could* expect that the result of 'stack query
375+
-- global-hints ghc-boot' is just a string literal. Seems easier
376+
-- for to expect the first line of the output to be the literal.
377+
| ["global-hints"] `isPrefixOf` selectors0 = (<> ("\n" <> globalHintsComment))
378+
| otherwise = id
379+
globalHintsLine = "\nglobal-hints:\n"
380+
globalHintsComment = T.concat
381+
[ "# Note: global-hints is experimental and may be renamed / removed in the future.\n"
382+
, "# See https://github.com/commercialhaskell/stack/issues/3796"
383+
]
370384
-- | Get the raw build information object
371385
rawBuildInfo :: HasEnvConfig env => RIO env Value
372386
rawBuildInfo = do

0 commit comments

Comments
 (0)