-
Notifications
You must be signed in to change notification settings - Fork 848
Description
I think we should add a --multi-module option to runghc / runhaskell. This way, standalone scripts can be multiple modules. On its own, this might seem confusing - why support that if ghc doesn't support it? The motivation is to support use-cases like School of Haskell, where we need to have multiple files in one "snippet".
The more ideal implementation would be to implement this as part of ghc - https://ghc.haskell.org/trac/ghc/ticket/2551 - however that ticket was closed due to lack of interest.
Here's how the stack implementation would look:
-
Assume that a line that starts with
moduleare located at a module header. This can be invalidated by strange module indentation, quasi-quotes, or multi-line strings. The answer to these corners is "don't do that". -
Consume pragma comments backwards, for every pragma type that is allowed atop module declarations.
-
Create a temp dir and populate it with the modules
-
Provide these modules to
runhaskell
Could also consider supporting this with ghci, but :reload won't work right. We could add direct support for this in intero, though.