Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Provide Stan integration #258

Closed
sir4ur0n opened this issue Jul 31, 2020 · 14 comments
Closed

[Feature] Provide Stan integration #258

sir4ur0n opened this issue Jul 31, 2020 · 14 comments
Labels
type: enhancement New feature or request

Comments

@sir4ur0n
Copy link
Collaborator

I propose HLS supports Stan integration, what do you think?

@Ailrun
Copy link
Member

Ailrun commented Jul 31, 2020

I think it would be great if possible, but as they use .hie file, we cannot use them for GHC < 8.8...

P.S. You are at the Haskell Love Conference, aren't you? :)

@sir4ur0n
Copy link
Collaborator Author

P.S. You are at the Haskell Love Conference, aren't you? :)

Yes, and I wanted to link the existing HLS-Stan integration issue to others. That's how I noticed there is no issue yet 😛

@lukel97 lukel97 added the type: enhancement New feature or request label Jul 31, 2020
@fendor
Copy link
Collaborator

fendor commented Jul 31, 2020

Hi, I started with this, but have no particular branch yet.
I once had a somewhat working impl, but we need haskell/ghcide#701, too.

@googleson78
Copy link
Contributor

haskell/ghcide#701 is now in hls master, what additional work needs to be done to get this working? @fendor

@jneira
Copy link
Member

jneira commented Nov 9, 2020

A required step for sure would be create a plugin to provide stan diagnostics and refactorings (?). I think hls-hlint-plugin could be a good starting point.

@googleson78
Copy link
Contributor

I was wondering if @fendor s work is something that's "almost done", and just needs a bit of cleanup.

@fendor
Copy link
Collaborator

fendor commented Nov 9, 2020

@googleson78 The work got stalled, and it was not that much, so we should rather re-write it. I don't have anything workable at the moment :(

@uhbif19
Copy link
Collaborator

uhbif19 commented May 9, 2022

I will try to work on this.

As far as I understand, it required to add new Rule, which will call Stan runAnalysis for each project file.

@fendor
Copy link
Collaborator

fendor commented May 9, 2022

Right, but ideally we re-use the .HIE files HLS is already generating, so we save some work.

@uhbif19
Copy link
Collaborator

uhbif19 commented May 13, 2022

@fendor @jneira

Stan requires HieTypes.HieFile while HLS GetHieAst returns HieAstResult, which contains only Module, not the whole file.
Is there any way to get HieTypes.HieFile out of HLS?

@pepeiborra
Copy link
Collaborator

pepeiborra commented May 15, 2022

HLS writes .hie files to disk, so you can definitely get a HieFile out of HLS by replicating the existing logic.
Something like this should do it:

getHieFile :: NormalizedFilePath -> Action (Maybe HieFile)
getHieFile nfp = runMaybeT $ do
    HAR{hieAst} <- MaybeT $ use GetHieAst nfp
    tmr <- MaybeT $ use TypeCheck nfp
    ghc <- MaybeT $ use GhcSession nfp
    msr <- MaybeT $ use GetModSummaryWithoutTimestamps nfp
    source <- lift $ getSourceFileSource nfp
    let exports = tcg_exports $ tmrTypechecked tmr
    typedAst <- MaybeT $ pure $ cast hieAst
    liftIO $ runHsc (hscEnv ghc) $ mkHieFile' (msrModSummary msr) exports typedAst source

@uhbif19
Copy link
Collaborator

uhbif19 commented May 15, 2022

@pepeiborra

Got error:

src/Ide/Plugin/Stan.hs:68:33: error:
    • No instance for (Typeable a) arising from a use of ‘cast’
    • In the second argument of ‘($)’, namely ‘cast hieAst’
      In the second argument of ‘($)’, namely ‘pure $ cast hieAst’
      In a stmt of a 'do' block: typedAst <- MaybeT $ pure $ cast hieAst
   |
68 |     typedAst <- MaybeT $ pure $ cast hieAst
   |                                 ^^^^^^^^^^^

@pepeiborra
Copy link
Collaborator

Add a Typeable constraint in the HAR constructor of the HieAstResult data type

@uhbif19
Copy link
Collaborator

uhbif19 commented May 16, 2022

@pepeiborra Thank you very much, your code worked.

Created WIP PR.

pepeiborra pushed a commit that referenced this issue Jul 27, 2022
sloorush pushed a commit to sloorush/haskell-language-server that referenced this issue Sep 12, 2022
@July541 July541 closed this as completed May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants