rikvdkleij / intellij-haskell

IntelliJ plugin for Haskell
https://rikvdkleij.github.io/intellij-haskell/
Apache License 2.0
1.32k stars 94 forks source link

Unable to create a project on windows #669

Open PierreVieira opened 3 years ago

PierreVieira commented 3 years ago

I'm doing the following step by step:

1) image

2) image

3) image

4) image

5) image

But I'm getting this error: image

My setup:

IntelliJ IDEA 2021.2.1 (Ultimate Edition)
Build #IU-212.5080.55, built on August 24, 2021
Licensed to Pierre Vieira
Subscription is active until December 15, 2021.
For educational use only.
Runtime version: 11.0.11+9-b1504.16 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1469M
Cores: 8
Non-Bundled Plugins: com.wakatime.intellij.plugin (13.1.0), org.jetbrains.jumpToLine (0.1.7), intellij.haskell (1.0.0-beta88), org.jetbrains.kotlin (212-1.5.31-release-546-IJ4638.7), Dart (212.5080.8), io.flutter (61.2.4)
Kotlin: 212-1.5.31-release-546-IJ4638.7
FelipeSanchezCalzada commented 3 years ago

Same problem...

s373r commented 3 years ago

Hello all! @PierreVieira @FelipeSanchezCalzada (and folks who made reactions: @Yochyo, @senior-zero)

I guess it can be helpful for you and future searchers (like me before) as well

Had the same error but after that, I re-read the README and got a thing: to start working we need to open an already created project; not to create a fresh one

Steps

  1. Install stack (https://get.haskellstack.org/stable/windows-x86_64-installer.exe)
  2. Reopen a terminal application to load updated PATH env variable
  3. In your working directory, execute to create a project helloworld:
    stack new helloworld new-template
  4. Now we be able to open helloworld directory via IntelliJ IDEA
  5. Wait for background tasks to finish
  6. Done! We can start our immersion in the wonderful world of functional programming

Demo

изображение

Message update history

PierreVieira commented 3 years ago

Hello all! @PierreVieira @PierreVieira (and folks who made reactions: @Yochyo, @senior-zero)

I guess it can be helpful for you and future searchers (like me before) as well

Had the same error but after that, I re-read the README and got a thing: to start working we need to open an already created project; not to create a fresh one

Steps

  1. Install stack (https://get.haskellstack.org/stable/windows-x86_64-installer.exe)
  2. Reopen a terminal application to load updated PATH env variable
  3. In your working directory, execute to create a project helloworld:
stack new helloworld new-template
  1. Now we be able to open helloworld directory via IntelliJ IDEA
  2. Wait for background tasks to finish
  3. Done! We can start our immersion in the wonderful world of functional programming

Demo

изображение

It seems to me that the project started successfully on IntelliJ. Although I get some error messages like: REPL couldn't be started for target "helloworld:test:helloworld-test" due to: cannot satisfy -package helloworld-0.1.0.0 Could you let me know if there is any easy way to run Main.hs (created by the instruction steps you provided), present in helloworld/app by IntelliJ?

rikvdkleij commented 3 years ago

Sorry for my late response.

@s373r Thanks for your help!

Looking to screenshot number 5, the project location should be including the project folder.

s373r commented 3 years ago

It seems to me that the project started successfully on IntelliJ. Although I get some error messages like: REPL couldn't be started for target "helloworld:test:helloworld-test" due to: cannot satisfy -package helloworld-0.1.0.0 Could you let me know if there is any easy way to run Main.hs (created by the instruction steps you provided), present in helloworld/app by IntelliJ?

@PierreVieira, I think we have several options[^1] here:

Preparations: let's create a new project from scratch

stack new run-demo simple
#                  ^^^^^^
# "simple" template is a bit lighter than the one used before ("new-template")

Open the previously created project in IntelliJ IDEA

1) Run without compilation

much faster on Windows[^2]

The commands here and below can be executed through the built-in terminal (Alt + F12) directly from the IDE

stack runghc -- .\src\Main.hs

2) Build[^3] and run an executable

Setup and use Run target

To create the action we need (images below are clickable)

  1. Click "Add configuration" button
  2. Click "Add New Configuration" plus button
  3. Search and choose "Haskell Stack Runner" (courteously provided to us by intellij-haskell plugin)
  4. Name the created action as you prefer
  5. [Optional] You can delete Build step since our command has already contained building
  6. Click "Run" button

Internally that give us a command (slower) but in this case, we have Run action (aka play button or Shift+F10 shortcut on default keymap):

stack build --exec run-demo

Nota bene

much faster, faster & slower markers depend on my hardware -- you can get other results. I recommend make experiments with all of them and chouse more comfortable one

Used materials

https://www.fpcomplete.com/haskell/tutorial/stack-script/ https://stackoverflow.com/questions/34842333/is-there-a-stack-run-similar-to-cabal-run https://hackage.haskell.org/package/stack-run

[^1]: I'm pretty new to Haskell developer tools, so any feedback is welcome! [^2]: For studying/quick changes, that looks good from a time perspective [^3]: Just run if no changes in source code