ReReStartingHaskell
This is version . It is not the current version, and thus it cannot be edited.
[Back to current version]   [Restore this version]

11 Nov 2017: Re-re-starting my adventures in Haskell, for no particularly good reason.

Try the first Project Euler problem: https://projecteuler.net/problem=1

GitHub repo is here: https://github.com/JohnL4/ProjectEuler

...aaaaand, now I have a blank editor in front of me. Now what?

Output#

putStr and putStrLn for printing to stdout. NOTE: This only prints strings. Use print as a more general-purpose output.

See this page: 2015-09-27-writing-a-simple-haskell-script-from-scratch

So... the first problem is adding ghc to your path in emacs (if you use that editor).

Stack#

Actually, a better choice is to install stack, which managed the entire toolchain for you, kind of like npm does for Node.

See https://docs.haskellstack.org/en/stable/install_and_upgrade/, and http://haskell.github.io/haskell-mode/manual/latest/Compilation.html. After that, you should be off to the races.

Done#

Ok, yay, me. I wrote a Haskell program in an afternoon, after a long break of not writing Haskell. I'm getting better at this!

(See https://github.com/JohnL4/ProjectEuler/blob/master/Haskell/Problem001/app/Main.hs.)

...Aaaand, oh, darn, there are a couple of really elegant and obvious Haskell one-liners that do the same thing as my program. Dang it!

Oh well, at least I brushed up on my Haskell skillz. Sort of.

Actually, they're just shorter and maybe more obvious. They may not be more elegant because they start with a full list of integers in range [1..999] and then eliminate invalid values.