@@ -24,7 +24,7 @@ module Stack.Build
24
24
import Stack.Prelude
25
25
import Data.Aeson (Value (Object , Array ), (.=) , object )
26
26
import qualified Data.HashMap.Strict as HM
27
- import Data.List ((\\) )
27
+ import Data.List ((\\) , isPrefixOf )
28
28
import Data.List.Extra (groupSort )
29
29
import Data.List.NonEmpty (NonEmpty (.. ))
30
30
import qualified Data.List.NonEmpty as NE
@@ -347,7 +347,7 @@ queryBuildInfo :: HasEnvConfig env
347
347
queryBuildInfo selectors0 =
348
348
rawBuildInfo
349
349
>>= select id selectors0
350
- >>= liftIO . TIO. putStrLn . decodeUtf8 . Yaml. encode
350
+ >>= liftIO . TIO. putStrLn . addGlobalHintsComment . decodeUtf8 . Yaml. encode
351
351
where
352
352
select _ [] value = return value
353
353
select front (sel: sels) value =
@@ -366,7 +366,21 @@ queryBuildInfo selectors0 =
366
366
where
367
367
cont = select (front . (sel: )) sels
368
368
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 = " \n global-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
+ ]
370
384
-- | Get the raw build information object
371
385
rawBuildInfo :: HasEnvConfig env => RIO env Value
372
386
rawBuildInfo = do
0 commit comments