Skip to content

Regression with ApplicativeDo in 8.10-rc1

This program fails to compile in GHC 8.10-rc1:

-- Build.hs
{-# LANGUAGE ApplicativeDo #-}
module Build (configRules) where

type Action = IO
type Rules = IO

type Config = ()

(%>) :: String -> (String -> Action ()) -> Rules ()
(%>) = undefined

command_ :: [String] -> String -> [String] -> Action ()
command_ = undefined

recursive :: Config -> String -> [String] -> IO (FilePath, [String])
recursive = undefined

liftIO :: IO a -> Action a
liftIO = id

need :: [String] -> Action ()
need = undefined

historyDisable :: Action ()
historyDisable = undefined

get_config :: () -> Action Config
get_config = undefined

configRules :: Rules ()
configRules = do
  "snapshot" %> \out -> do
    historyDisable -- 8.10-rc1 refuses to compile without bind here
    config <- get_config ()
    need []
    (exe,args) <- liftIO $ recursive config "snapshot" []
    command_ [] exe args
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.0.20200123

$ ghc -c Build.hs -fforce-recomp

Build.hs:38:5: error:
    • Couldn't match expected type ‘IO ([String], String)’
                  with actual type ‘([String], FilePath)’
    • In the expression:
        do historyDisable
           config <- get_config ()
           need []
           (exe, args) <- liftIO $ recursive config "snapshot" []
           command_ [] exe args
      In the second argument of ‘(%>)’, namely
        ‘\ out
           -> do historyDisable
                 config <- get_config ()
                 need []
                 (exe, args) <- liftIO $ recursive config "snapshot" []
                 command_ [] exe args’
      In a stmt of a 'do' block:
        "snapshot"
          %>
            \ out
              -> do historyDisable
                    config <- get_config ()
                    need []
                    (exe, args) <- liftIO $ recursive config "snapshot" []
                    command_ [] exe args
   |
38 |     config <- get_config ()
   |     ^^^^^^

If I instead write () <- historyDisable compilation works.

Edited by adam
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information