WIP: Allow signatures without bindings
Builds on !9999, from where I took the implementations of some of the helper functions.
The author of that MR mentioned that they got stuck actually emitting the binding for the type signature, and I wanted to take a crack at it myself following Simon's (very helpful) outline in the original MR, before getting this into a mergeable state. In particular, that means that this MR in its current state doesn't even add the flag that would control whether or not this feature was activated, which I intend to do once I get the feature actually working, which is the part I need some help with.
The current implementation doesn't work; GHC seems to ignore the binding that is generated:
==================== Renamer ====================
Main.x :: Int
Main.main :: IO ()
Main.main = print x
Main.x = Control.Exception.Base.undeclaredError ""#
binds []
sigs []
uses [(Nothing, {}), (Nothing, {})]
Main.hs:6:14: error: [GHC-88464] Variable not in scope: x
|
6 | main = print x
|
My best guess is that I need to make the generated RHS for the undeclared binding somehow participate in dependency analysis in rnValBindsRHS
, so that GHC can figure out how to wire the references to the undeclared identifier to the newly generated binding, but I'm not sure how to do so. I felt that unioning them with mbinds
before the call to depAnalBinds
seemed like a reasonable way of doing so, but there I was stumped by the type indices not matching up (HsBindLR GhcPs GhcRn
vs HsBindLR GhcRn GhcRn
or something similar) and wanted to make sure I was on the right track to begin with. (Is genSimpleFunBind
the right way to build the rhses, for instance?)