Description
I hope you don't mind me asking, but I am trying to find a piece of code that parses the first comment from the .hs file that is provided to stack as a script.
I am talking about https://docs.haskellstack.org/en/stable/GUIDE/#script-interpreter functionality.
I looked into https://github.com/commercialhaskell/stack/blob/master/src/main/Main.hs and I see that https://github.com/commercialhaskell/stack/blob/master/src/Stack/Options/ScriptParser.hs is used to parse the options and that https://github.com/commercialhaskell/stack/blob/master/src/Stack/Script.hs takes those options and executes script.
This makes sense in the case when stack is called directly, e.g. stack script myScript.hs
.
However, in the case when it is called via shebang, I am assuming that stack first needs to get hold of that first comment in the .hs file, be it one-line or multi-line comment -> so there must be some step where that comment is parsed and then the usual flow of the code goes (parsing the options, calling scriptCmd from Script.hs.).
I just can't find that piece of code -> thank you for any directions!