How to setup IDE for development with Purescript?

Hi,

I recently learnt purescript and I really like it. Now I would like to build stuff with it.

So far I’ve been using VSCode for my experimentations with the language. But it is far from being a great development experience.

May I ask what you are using, and what setup you recommend to productively write purescript?

For reference, I’m used to write Kotlin, Rust and Elm code with IntelliJ (and related plugins).

I’m not afraid of learning new tools. As long as they provide a decent experience (immediate error checking, refactoring, autocompletion, import optimization, etc.)

Thanks for your help.

Cheers.

1 Like

just checking - you have installed and used the vs-code language support and purescript ide plugins but you don’t find them to be sufficient?

just checking - you have installed and used the vs-code language support and purescript ide plugins but you don’t find them to be sufficient?

I installed the first proposed plugin for vs-code. And It does work to some extend. I have (limited) auto-completion for instance. But I cannot jump to a symbol definition, I have to save before seeing the errors, I have to re-write the function name after writing its signature, etc.

Maybe I didn’t install the best plugin for vscode? Maybe I have to configure it? Or maybe I need multiple plugins?

P.S: Worth noting that it is the first time I used vs-code. I may not know obivous stuff about it.

1 Like

First one offered should be this one: https://github.com/nwolverson/vscode-ide-purescript

Don’t think you’ll need others (well, i you may want more but i don’t think you’ll get better than that right now)

I find it works really well for me but it does require a successful compile for it to be able to jump to definition, jump to reference, case split and so on.

You do only trigger the error detection on save, i don’t find that a problem but YMMV

The import completion is phenomenally useful, IMO - with one caveat, you need to be alert to what completion you are accepting as the completions are by symbol name only (not signature) so you can occasionally make life very hard for yourself by auto-completing something that then generates mysterious type-errors. It’s not a major problem but rather something to be aware of.

1 Like

First one offered should be this one: https://github.com/nwolverson/vscode-ide-purescript

Yep, that’s the one I have.

Thanks @afc, Maybe I am expecting too much functionality to be available even on a non-compiling state. Good to know it must compile first.

However, even on a compiling state, I cannot jump to symbols usage/implementation. Is it supposed to work?

EDIT: I found that jumps to definition actually works “sometime”. Still not clear why it doesn’t always work. And jump to usage, simply doesn’t seem available to me. :thinking:

That’s fine. I’m used to this behavior. That’s the same with other languages.

But I cannot “optimize” imports for example. (automatically removing unneeded imports).

Also something which is quite painful is that I cannot generate a typeclass implementation. That forces me to lookup for the function signatures in the docs and retype them manually. (Not mentionning I cannot jump to the typeclass definition)

1 Like

Cmd-. should trigger a context menu for suggestions - like this image

for specific suggestions, when your cursor is on the same line as the suggestion indicator (wavy orange underline) you can also mouseclick the little lightbulb, and as you see here, get offered the fix for just that particular situation: image

wrt instances, there’s some limited support on completion of instance keyword and you should be able to hover the typeclass like so

which is probably not as much as you are wanting but it’s not nothing!

1 Like

Thanks @afc.

I just realized that it suggest quick-fixes only after I save. I think I have to get used to spam Ctrl-S. Do you know a plugin for vscode that automatically save the file each time I type a character?

i think you’re better getting used to the reflexive save, TBH, running the compiler for every character is not going to work, i think. (maybe if it were debounced to some number of idle seconds but that’s probably worse experience than hitting save)

I think you’ll find that it’s still a productive environment - speaking only for myself i find that i don’t need that constant nannying of lint that i do need in JS in Haskell-like languages.

I do have immediate linting when working with Haskell and Elm, and that is definitely a confort to me. But I will probably get used-to the ctrl+s spam.

Thanks @afc for your help :wink:

1 Like

Don’t need a plugin you can enable auto save, click on File menu and enable auto save, it will save every 1 second by default

1 Like