Skip to content

Fix ghcide-2.6.0.0 patch to account for OsPath migration

ghc@c8ece0df made the following change to mkHomeModLocation's type signature:

-mkHomeModLocation :: FinderOpts -> ModuleName -> FilePath -> ModLocation
+mkHomeModLocation :: FinderOpts -> ModuleName -> OsPath   -> ModLocation

This change breaks ghcide, as seen in this failing CI job:

[ 6 of 76] Compiling Development.IDE.GHC.Compat.Core ( src/Development/IDE/GHC/Compat/Core.hs, dist/build/Development/IDE/GHC/Compat/Core.o, dist/build/Development/IDE/GHC/Compat/Core.dyn_o )
src/Development/IDE/GHC/Compat/Core.hs:576:85: error: [GHC-83865]
    • Couldn't match type ‘[Char]’
                     with ‘os-string-2.0.2.2:System.OsString.Internal.Types.OsString’
      Expected: System.OsPath.Types.OsPath
        Actual: FilePath
    • In the third argument of ‘GHC.mkHomeModLocation’, namely ‘f’
      In the second argument of ‘($)’, namely
        ‘GHC.mkHomeModLocation (GHC.initFinderOpts df) mn f’
      In the expression:
        pure $ GHC.mkHomeModLocation (GHC.initFinderOpts df) mn f
    |
576 | mkHomeModLocation df mn f = pure $ GHC.mkHomeModLocation (GHC.initFinderOpts df) mn f
    |                                                                                     ^

We should update the ghcide patch accordingly. Perhaps fixing it would be as simple as changing f to (unsafeEncodeUtf f), similarly to how GHC itself does it in the commit above.