Strictness/demand info for a Name
Dear all, I’m trying to bring the information about demand and strictness to the Haskell Language Server, but I cannot find a way to do so. I was wondering whether you could help me :) Here’s my understanding; please correct me if I’m wrong: - The analysis runs on Core, so getting this information for the current file would require to run the compiler further than type checking, which is quite expensive, - However, this analysis should somehow use known information about imported functions, which should be readily available somewhere, - If the above is true, what is the simplest way to get the information for imported things? As I mentioned above, I would prefer not to run the compiler further than the type checking phase, since otherwise it gets too expensive for IDE usage. Right now HLS uses the information from the .hie files. In fact, this goes into the more general question of how to show information from different analyses within the IDE; I guess solving the case for strictness/analysis may open the door to more (maybe everything recorded inside a `Id`?) Regards, Alejandro ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Re: Strictness/demand info for a Name
You look at `dmdSigInfo` in `IdInfo`. Matt On Thu, Jan 13, 2022 at 2:20 PM Alejandro Serrano Mena wrote: > > Dear all, > > I’m trying to bring the information about demand and strictness to the > Haskell Language Server, but I cannot find a way to do so. I was wondering > whether you could help me :) > > Here’s my understanding; please correct me if I’m wrong: > > The analysis runs on Core, so getting this information for the current file > would require to run the compiler further than type checking, which is quite > expensive, > However, this analysis should somehow use known information about imported > functions, which should be readily available somewhere, > If the above is true, what is the simplest way to get the information for > imported things? As I mentioned above, I would prefer not to run the compiler > further than the type checking phase, since otherwise it gets too expensive > for IDE usage. Right now HLS uses the information from the .hie files. > > > In fact, this goes into the more general question of how to show information > from different analyses within the IDE; I guess solving the case for > strictness/analysis may open the door to more (maybe everything recorded > inside a `Id`?) > > Regards, > Alejandro > ___ > ghc-devs mailing list > ghc-devs@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Re[2]: Strictness/demand info for a Name
Yes, Matt is right. `dmdSigInfo` describes the how a function Id uses its arguments and free variables, whereas `demandInfo` describes how a (local, mostly) Id is used. Note that if you wanted to go beyond type-checking, you could probably run the analysis on the desugaring of the current module quite easily. But the results would be misleading, as prior optimisations (that you probably don't want to run) may arrange the program in a way that demand analysis has an easier time. -- Originalnachricht -- Von: "Matthew Pickering" An: "Alejandro Serrano Mena" Cc: "GHC developers" Gesendet: 13.01.2022 15:38:29 Betreff: Re: Strictness/demand info for a Name You look at `dmdSigInfo` in `IdInfo`. Matt On Thu, Jan 13, 2022 at 2:20 PM Alejandro Serrano Mena wrote: Dear all, I’m trying to bring the information about demand and strictness to the Haskell Language Server, but I cannot find a way to do so. I was wondering whether you could help me :) Here’s my understanding; please correct me if I’m wrong: The analysis runs on Core, so getting this information for the current file would require to run the compiler further than type checking, which is quite expensive, However, this analysis should somehow use known information about imported functions, which should be readily available somewhere, If the above is true, what is the simplest way to get the information for imported things? As I mentioned above, I would prefer not to run the compiler further than the type checking phase, since otherwise it gets too expensive for IDE usage. Right now HLS uses the information from the .hie files. In fact, this goes into the more general question of how to show information from different analyses within the IDE; I guess solving the case for strictness/analysis may open the door to more (maybe everything recorded inside a `Id`?) Regards, Alejandro ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Re: Re[2]: Strictness/demand info for a Name
Thanks for the pointers! :) Knowing this, let me maybe rephrase my question: is it possible to get demand information of identifiers *without* running the analysis itself? Alejandro El 13 ene 2022 15:45:29, Sebastian Graf escribió: > Yes, Matt is right. > > `dmdSigInfo` describes the how a function Id uses its arguments and free > variables, whereas > `demandInfo` describes how a (local, mostly) Id is used. > > Note that if you wanted to go beyond type-checking, you could probably > run the analysis on the desugaring of the current module quite easily. > But the results would be misleading, as prior optimisations (that you > probably don't want to run) may arrange the program in a way that demand > analysis has an easier time. > > -- Originalnachricht -- > Von: "Matthew Pickering" > An: "Alejandro Serrano Mena" > Cc: "GHC developers" > Gesendet: 13.01.2022 15:38:29 > Betreff: Re: Strictness/demand info for a Name > > You look at `dmdSigInfo` in `IdInfo`. > > > Matt > > > On Thu, Jan 13, 2022 at 2:20 PM Alejandro Serrano Mena > > wrote: > > > > > > Dear all, > > > > > > I’m trying to bring the information about demand and strictness to the > Haskell Language Server, but I cannot find a way to do so. I was wondering > whether you could help me :) > > > > > > Here’s my understanding; please correct me if I’m wrong: > > > > > > The analysis runs on Core, so getting this information for the current > file would require to run the compiler further than type checking, which is > quite expensive, > > > However, this analysis should somehow use known information about > imported functions, which should be readily available somewhere, > > > If the above is true, what is the simplest way to get the information > for imported things? As I mentioned above, I would prefer not to run the > compiler further than the type checking phase, since otherwise it gets too > expensive for IDE usage. Right now HLS uses the information from the .hie > files. > > > > > > > > > In fact, this goes into the more general question of how to show > information from different analyses within the IDE; I guess solving the > case for strictness/analysis may open the door to more (maybe everything > recorded inside a `Id`?) > > > > > > Regards, > > > Alejandro > > > ___ > > > ghc-devs mailing list > > >ghc-devs@haskell.org > > >http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs > > ___ > > ghc-devs mailing list > > ghc-devs@haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs > > > ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Re[4]: Strictness/demand info for a Name
Yes, every imported identifier from a module that was compiled with optimisations should have the proper analysis information in its IdInfo. So if you have `base` somewhere in one of your compiled libraries and load it, then the identifier of `GHC.OldList.map` will have an `idDmdSig` that says it's strict in the list parameter. At least that's how it works in GHC, where these IdInfos are populated with the information from the loaded interface files. The situation with HLS might be different, although I wouldn't expect that. -- Originalnachricht -- Von: "Alejandro Serrano Mena" An: "Sebastian Graf" Cc: "GHC developers" ; "Matthew Pickering" Gesendet: 13.01.2022 16:43:50 Betreff: Re: Re[2]: Strictness/demand info for a Name Thanks for the pointers! :) Knowing this, let me maybe rephrase my question: is it possible to get demand information of identifiers without running the analysis itself? Alejandro El 13 ene 2022 15:45:29, Sebastian Graf escribió: Yes, Matt is right. `dmdSigInfo` describes the how a function Id uses its arguments and free variables, whereas `demandInfo` describes how a (local, mostly) Id is used. Note that if you wanted to go beyond type-checking, you could probably run the analysis on the desugaring of the current module quite easily. But the results would be misleading, as prior optimisations (that you probably don't want to run) may arrange the program in a way that demand analysis has an easier time. -- Originalnachricht -- Von: "Matthew Pickering" An: "Alejandro Serrano Mena" Cc: "GHC developers" Gesendet: 13.01.2022 15:38:29 Betreff: Re: Strictness/demand info for a Name You look at `dmdSigInfo` in `IdInfo`. Matt On Thu, Jan 13, 2022 at 2:20 PM Alejandro Serrano Mena wrote: > > Dear all, > > I’m trying to bring the information about demand and strictness to the Haskell Language Server, but I cannot find a way to do so. I was wondering whether you could help me :) > > Here’s my understanding; please correct me if I’m wrong: > > The analysis runs on Core, so getting this information for the current file would require to run the compiler further than type checking, which is quite expensive, > However, this analysis should somehow use known information about imported functions, which should be readily available somewhere, > If the above is true, what is the simplest way to get the information for imported things? As I mentioned above, I would prefer not to run the compiler further than the type checking phase, since otherwise it gets too expensive for IDE usage. Right now HLS uses the information from the .hie files. > > > In fact, this goes into the more general question of how to show information from different analyses within the IDE; I guess solving the case for strictness/analysis may open the door to more (maybe everything recorded inside a `Id`?) > > Regards, > Alejandro > ___ > ghc-devs mailing list >ghc-devs@haskell.org >http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs