MercuryTechnologies / ghciwatch

Load a GHCi session for a Haskell project and reload it when source files change
https://mercurytechnologies.github.io/ghciwatch/
MIT License
111 stars 10 forks source link

Parse Haskell source paths more reliably #302

Open 9999years opened 4 months ago

9999years commented 4 months ago

Haskell source paths, as GHC understands them, are remarkably permissive: they must end with one of the source extensions (now more accurately listed here, with references to the upstream GHC code), but can otherwise contain quirks up to and including multiple extensions, whitespace, and newlines.

GHCi is actually even more lenient than this in what it accepts; it'll automatically append .hs and .lhs to paths you give it and check if those exist, but fortunately they get printed out in :show targets and diagnostics as the resolved source paths:

ghci> :add src/MyLib
[1 of 1] Compiling MyLib            ( src/MyLib.hs, interpreted )

ghci> :show targets
src/MyLib.hs

ghci> :add src/Foo
target ‘src/Foo’ is not a module name or a source file

ghci> :add src/MyLib.lhs
File src/MyLib.lhs not found

ghci> :add "src/ Foo.hs"
File src/ Foo.hs not found

ghci> :add "src\n/Foo.hs"
File src
/Foo.hs not found

Split off of #297

linear[bot] commented 4 months ago

DUX-2349 Parse Haskell source paths more reliably