Newbie playing with haskell stack scripting and turtle.
- Created a folder
stack-scripts. Thought if it looks good, then I'll create some haskell utils for me to replace bash scripts. Created a file named
turtle.hswith following text:#!/usr/bin/env stack -- stack --resolver lts-11.2 script {-# LANGUAGE OverloadedStrings #-} import Turtle main = echo "Hello!"made the
chmod +x turtle.hsand tried to execute it.Got the following error message:
turtle.hs:1:1: error: File name does not match module name: Saw: `Main' Expected: `Turtle' | 1 | #!/usr/bin/env stack | ^
It does what it should if I rename turtle.hs to turtle.sh. But then I have no syntax highlighting for haskell.
Also it works if I rename it to something-other.hs. But then Haskero (VSCode) complains about import Turtle line: Couldn't guess that module name. Does it exist?
What I'm missing here? Running in git bash on Windows.
Apparently you need to give the script a different name as the module name in which the code runs, will automatically be derived from it and now it will conflict with the imported
Turtlemodule. Renaming it toturtlescript.hsand thenworked for me.