Started with Haskell - And what did I find?

As a starter with Haskell, here my experience. Hope to hear and find a open ear, and a help hand as response?

The list of trails, which failed to get a Haskell working, from blog post till the official Haskell get started site is to long to mention or documented her, but I will come one in particular this one:

Haskell getting started from the official site:

wget -qO- https://get.haskellstack.org/ | sh

made a file HelloWorld.hs

#!/usr/bin/env stack
-- stack --resolver lts-13.7 script

main :: IO ()
main = putStrLn "Hello World"
stack HelloWorld.hs
Downloaded lts-13.7 build plan.    
AesonException "Error in $.packages.cassava.constraints.flags['bytestring--lt-0_10_4']: Invalid flag name: \"bytestring--lt-0_10_4\""    

If you call Haskell a functional language, which it is, then it would good to see that blog post and official explanation of Haskell code is functional - in the meaning of working. Maintains, and keep a eye on what you publish. And reach out a hand to beginners, they only will stay as long as you reach out your hand and is it trust wards. In practical sens, Haskell is poor documented. And I would not recommend it to others, because of that. If this has no meaning for the developers?

Crojav

What is the version of your stack executable? Yhis error reminds me of a bug from stack version <1.7.0 i think? Maybe try running stack upgrade? your stack executable should be of version >2

$ stack upgrade
Current Stack version: 1.5.1, available download version: 2.1.3
Newer version detected, downloading
Querying for archive location for platform: linux-x86_64-static
Downloading from: https://github.com/commercialhaskell/stack/releases/download/v2.1.3/stack-2.1.3-linux-x86_64-static.tar.gz
Download complete, testing executable
Version 2.1.3, Git revision 636e3a759d51127df2b62f90772def126cdf6d1f (7735 commits) x86_64 hpack-0.31.2

WARNING: Installation path /home/timetochange/.local/bin not found on the PATH environment variable
New stack executable available at /home/timetochange/.local/bin/stack

Right. now try stack HelloWorld.hs again.

$ stack HelloWorld.hs
Downloaded lts-13.7 build plan.    
AesonException "Error in $.packages.cassava.constraints.flags['bytestring--lt-0_10_4']: Invalid flag name: \"bytestring--lt-0_10_4\""

oh, right, the message in your previous message said it installed the new stack executable at /home/timetochange/.local/bin/stack, but ~/.local/bin is not in your path so when you write stack it still refers to the old stack which before the upgrade.

Either add ~/.local/bin/ to your path, or place the new stack executable (found in /home/timetochange/.local/bin/stack) instead of the old one. you can do that with mv /home/timetochange/.local/bin/stack $(which stack). you might need to sudo that though.

$ stack HelloWorld.hs
Unpacking GHC into /home/timetochange/.stack/programs/x86_64-linux/ghc-8.6.3.tem                                                                                rts-1.0: Warning: .:466:1: The field "hugs-options" is deprecated. hugs isn't supported anymore
Hello World       

What to do with "The field “hugs-options” is deprecated …

Thanks, at least it looks that something start to work! Maybe as you have seen I have posted more question under Learn would be nice to see that some one takes a look at them to?

Strangely enough this happen when I stack another file.hs It start to download again GHC

stack myDrop.hs
stack: WARNING! Expecting stack options comment at line 1, column 1
stack: WARNING! Missing or unusable stack options specification
stack: WARNING! Using runghc without any additional stack options
Unpacking GHC into /home/timetochange/.stack/programs/x86_64-linux/ghc-8.6.5.tem                                                                                Inrts-1.0: Warning: .:466:1: The field "hugs-options" is deprecated. hugs isn't supported anymore

What to do with "The field “hugs-options” is deprecated …

It happens because stack just installed ghc for you. See that the next time you run it it will not appear.

Strangely enough this happen when I stack another file.hs It start to download again GHC

Stack will install the relevant compiler and packages according to the resolver described to it. see that in the HelloWorld.hs you wrote: -- stack --resolver lts-13.7 script.

myDrop.hs either has something similar to that or is using “the global” configuration described in .stack/global-project/stack.yaml (I recommend opening that file and update the resolver to something newer such as lts-14.20.

You can learn more about how to invoke ghc and ghci from stack and how to build stack programs in the three tutorials on this page: https://tech.fpcomplete.com/haskell/get-started

First off all thanks for helping

The strange think about this for me is, why this is not mentioned on the official Haskell site https://www.haskell.org/ the place where I started.

Over all my experience with Haskell is not that good, documentation is not well maintained. Getting started is a pain in the ass so to say. Even with Python as my back ground, what will this all mean for people who have not programming skills …? I would not recommend Haskell for all of this.

What specifically would you like to be written? Note that you could also open an issue at the www.haskell.org repository.

Well a better question would be, what would you like to be rewritten?
I found to many inconsistent examples, that it not easy to drop them all here, but the list is growing…

again a example: book.realworldhaskell.org/defining-types-streamlining-functions.html

-- file: ch03/BookStore.hs
data MagazineInfo = Magazine Int String [String]
                    deriving (Show)

stack exec -- ghc BookStore.hs
[1 of 1] Compiling Main             ( BookStore.hs, BookStore.o )

BookStore.hs:1:1: error:
    The IO action ‘main’ is not defined in module ‘Main’
  |
1 | myInfo = Book 9780135072455 "Algebra of Programming"
  | ^

And I all ready dropped more in other topic on this forum, as you maybe have seen?

Well and that starters has to open a issue on a official site to let them know that there examples are not working, is that the way Haskell thinks, functional - meaning working consistent - programming???

It would by great to see not only Haskell codes is consistent, but also there documentation!

The chapter in the book you tried to link to mentions using ghci but you have tried to use ghc instead which is why you are having problems with that.

Also note that there may be other issues with real world haskell as it was written in 2007. I’m aware that someone is currently working on updating it.

Some issues you have may be caused by third party libraries you tried to use or by a blocking bug in an old stack executable which will hopefully won’t repeat itself.

You don’t have to open a ticket if you don’t want to.

Here with ghci:

$ ghci 
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Prelude> :load BookStore.hs 
[1 of 1] Compiling Main             ( BookStore.hs, interpreted )

BookStore.hs:1:10: error:
    Data constructor not in scope:
      Book :: Integer -> [Char] -> [[Char]] -> t
Failed, modules loaded: none.
Prelude>

Some issues you have may be caused by third party libraries you tried to use or by a blocking bug in an old stack executable which will hopefully won’t repeat itself.

Well do you think some one who start with Haskell has to find and resolve all this issue? That is most unfriendly Haskell welcome!

Maybe you are willing to help me I show me working starters examples?

What is BookStore.hs ? Where did you take it from?

Well do you think some one who start with Haskell has to find and resolve all this issue? That is most unfriendly Haskell welcome!

A new haskell user is not expected to download an old version of stack (bugs happen), nor is expected to try and use a random project (making sure a project compiles and works and that is the docs can only be the responsibility of the project’s maintainer. This is true for any and all programming languages). They are currently expected to follow one of the guides to the language and use recommended libraries.

Maybe you are willing to help me I show me working starters examples?

Sure, what specifically are you looking for?

Bookstore.hs comes from the book

As I wrote I got Haskell from the official site:

wget -qO- https://get.haskellstack.org/ | sh

How would I know on for hand that it is buggy?

And why a new Haskell user is not expected to try random project??? That is the way I found a lot of working examples in Python and other languages. At least it is not mentioned on the Haskell site not to do so. It would be better to clear that up with a notification if that is the case.

Beside of that, it is confusing https://www.fpcomplete.com/introduction-to-haskell and on the other hand haskell .org which one is the official Haskell one and which to follow?

It’s the responsibility of the maintainer of project - blog e.t.c I am talking about to.

Your first link typeclasses .com/ phrasebook/ hello-world ( I can’t place more then two links)

$ nano hello-world.hs
main = putStrLn "hello world"
$ runhaskell hello-world.hs
hello world
$ ghc hello-world.hs
$ ls
hello-world hello-world.hi hello-world.hs hello-world.o
$ ./hello-world.hs
./hello-world.hs: regel 2: main: not found ( translate from my own languase )

Well this is what i mean - hope you get a better understanding of what I try to explain about the documentation of Haskell?

I’m sorry but I find it hard to believe that you ran that command and got stack v1.5.1 installed, that’s a version from 2017.

If you try a random project in any language it might not work, that’s just the way it is.

haskell.org is the official, I recommend following the fpcomplete one. I understand that this is confusing.

After compiling hello-world.hs, the result executable is hello-world. You are trying to run the source code itself instead of the compiled executable. This is not an issue of the documentation.

Stack version:

stackversion

After compiling hello-world.hs, the result executable is hello-world. You are trying to run the source code itself instead of the compiled executable. This is not an issue of the documentation.

I see what you mean, I tried to ./hello-world.sh It must be ./hello-world with out extension!

Thanks

I am follow exactly every step and compiled ,

No you don’t.
You 're trying to run a source file ./hello-world.hs.

You are ritght!
we post on the same time

stack was probably installed somewhere in the system and ~/.local/bin wasn’t in the $PATH.