From fd568bfcdefd219177965c3af9927563c04d3f6b Mon Sep 17 00:00:00 2001 From: Martin Sosic Date: Wed, 31 Aug 2022 22:37:45 +0200 Subject: [PATCH 1/4] Added get-started page. --- site/css/hl.css | 61 ++++++++++++++++ site/downloads.markdown | 7 ++ site/get-started.markdown | 142 ++++++++++++++++++++++++++++++++++++++ site/index.html | 2 +- site/templates/nav.html | 1 + 5 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 site/get-started.markdown diff --git a/site/css/hl.css b/site/css/hl.css index 2a885116..9f829c5a 100644 --- a/site/css/hl.css +++ b/site/css/hl.css @@ -4667,3 +4667,64 @@ pre .hs-keyglyph { min-width: 292.5px; width:100% } + +/* Boostrap-style callouts (nice informational boxes), + taken from https://codepen.io/chrisdpratt/pen/QWBqKY . +*/ + +.bs-callout { + padding: 0px 0px 10px 20px; + margin: 20px 0; + border: 1px solid #eee; + border-left-width: 5px; + border-radius: 3px; +} +.bs-callout h4 { + margin-top: 0; + margin-bottom: 5px; +} +.bs-callout p:last-child { + margin-bottom: 0; +} +.bs-callout code { + border-radius: 3px; +} +.bs-callout+.bs-callout { + margin-top: -5px; +} +.bs-callout-default { + border-left-color: #777; +} +.bs-callout-default h4 { + color: #777; +} +.bs-callout-primary { + border-left-color: #9E358F; +} +.bs-callout-primary h4 { + color: #9E358F; +} +.bs-callout-success { + border-left-color: #5cb85c; +} +.bs-callout-success h4 { + color: #5cb85c; +} +.bs-callout-danger { + border-left-color: #d9534f; +} +.bs-callout-danger h4 { + color: #d9534f; +} +.bs-callout-warning { + border-left-color: #f0ad4e; +} +.bs-callout-warning h4 { + color: #f0ad4e; +} +.bs-callout-info { + border-left-color: #5bc0de; +} +.bs-callout-info h4 { + color: #5bc0de; +} diff --git a/site/downloads.markdown b/site/downloads.markdown index 0173fb6a..20b98fca 100644 --- a/site/downloads.markdown +++ b/site/downloads.markdown @@ -4,6 +4,13 @@ page: downloads isDownloads: true --- +
+

+

Psssst!

+ Looking to get started with Haskell? If so, check out the [Get Started](/get-started) page! +

+
+ # Downloads ## Recommended installation instructions diff --git a/site/get-started.markdown b/site/get-started.markdown new file mode 100644 index 00000000..215fb993 --- /dev/null +++ b/site/get-started.markdown @@ -0,0 +1,142 @@ +--- +title: Get Started +page: get-started +isGettingStarted: true +--- + +# Get started +Welcome, new Haskeller! Read on to quickly set up your Haskell dev environment, execute your first lines of code, and get directions for further learning! + +## Content + - [Set up Haskell dev environment](#set-up-haskell-dev-environment) + - [GHCup: universal installer](#ghcup-universal-installer) + - [Editor](#editor) + - [Running first lines of code](#running-first-lines-of-code) + - [Writing your first Haskell program](#writing-your-first-haskell-program) + - [Join the community](#join-the-community) + - [Next steps](#next-steps) + +## Set up Haskell dev environment + +Complete Haskell dev environment consists of Haskell toolchain (compiler, language server, build tool) and editor with good haskell support. The quickest way to get this set up is to: + +1. Use GHCup to install and manage Haskell toolchain. +2. Use VSCode as the editor, with the Haskell extension installed. + +### GHCup: universal installer + +[GHCup](https://www.haskell.org/ghcup/#) is a universal installer for Haskell that will install for you everything you need to program in Haskell, and then will also help you manage those installations in the future (update, switch versions, ...). + +Follow instructions at [GHCup webpage](https://www.haskell.org/ghcup/#) to install GHCup. Then, use it to install the Haskell Toolchain, which consists of: + +1. **GHC** -> Haskell compiler. We will use it below to run our examples, but in practice, you will mostly be using a build tool like `cabal` or `Stack` to build your code, instead of `GHC` directly. +2. **HLS** -> Haskell Language Server -> You won't use this directly, instead your code editor will use it in the background to provide you with a great experience while editing Haskell code. +3. **cabal** -> Haskell build tool -> You will use this to structure your Haskell projects, build them, run them, define dependencies, ... +4. **Stack** -> Haskell build tool -> alternative to `cabal` + + +
+

+

cabal and Stack -> which one should I install?

+ We recommend installing both. Most Haskell projects can be built using Cabal, but some might require Stack. Installing both guarantees that you can use either, and while following the tutorial/book you can use whatever they recommend. +

+
+ +### Editor +**Visual Studio Code** is a popular choice with well supported editor integration. Install the [Haskell extension](https://marketplace.visualstudio.com/items?itemName=haskell.haskell) and you are all set. It should work out of the box and use your installation of HLS. + +To learn about support for other editors, check out [HLS docs for editor configuration](https://haskell-language-server.readthedocs.io/en/latest/configuration.html#configuring-your-editor). + +## Running first lines of code + +We have everything set up, let's use it! + +`GHC` brings an interactive interpreter called `GHCi` together with it, which is great for playing with Haskell and trying things out, so let's give it a spin. + +Run `ghci`, which should start a new prompt for you. + +Let's do a simple calculation to check Haskell's computing capabilities: +``` +> 6 + 3^2 * 4 +42 +``` + +42 is a nice even number, but what about the first 10 even numbers after it? +``` +> take 10 (filter even [43..]) +[44,46,48,50,52,54,56,58,60,62] +``` + +What is the sum of those? +``` +> sum it +530 +``` +**NOTE**: We used a special feature of GHCi here, which is a special `it` variable that remembers the result of the last expression. + +Great, you got the first taste of Haskell! Now let's get to running a real program. + +## Writing your first Haskell program + +In your editor, create a new file named `hello.hs`. + +Write the following in it: +```hs +main = do + putStrLn "Hello, everybody!" + putStrLn ("Please look at my favorite odd numbers: " ++ show (filter odd [10..20])) +``` + +You can now compile it with `ghc`, which will produce `hello` binary that we will then run: +``` +> ghc hello.hs +> ./hello +Hello, everybody! +Please look at my favorite odd numbers: [11,13,15,17,19] +``` + +There you go, you just wrote a short, polite program in Haskell! + +**TIP**: To interpret the source file directly, without producing any build artifacts, you can use the special `runghc` command like this: +``` +> runghc hello.hs +Hello, everybody! +Please look at my favorite odd numbers: [11,13,15,17,19] +``` + +**GHCI TIP**: You can also load your file directly into `ghci`, which will enable you to play with any functions and other definitions you defined in it. So for our example, we can just load `hello.hs` with ghci and then call the function `main` like this: +``` +> ghci hello.hs +GHCi, version 8.10.7: https://www.haskell.org/ghc/ :? for help +[1 of 1] Compiling Main ( hello.hs, interpreted ) +Ok, one module loaded. +> main +Hello, everybody! +Please look at my favorite odd numbers: [11,13,15,17,19] +``` + +## Join the community + +By joining the Haskell community you will find a great place to ask for help and learn about new developments in the Haskell ecosystem. + +Some of the most popular communities are: + + - [r/haskell](https://www.reddit.com/r/haskell/) + - [Haskell Discourse](https://discourse.haskell.org/) + - [https://wiki.haskell.org/IRC_channel](https://wiki.haskell.org/IRC_channel) + +We recommend joining right now, and don't be shy to ask for help! + +Check [https://www.haskell.org/community](https://www.haskell.org/community) for a full list of Haskell communities. + +## Next steps + +Popular free learning resources for beginners: + + - [Introductory Haskell course of the University of Pennsylvania (CIS194)](https://www.seas.upenn.edu/~cis1940/spring13/lectures.html) (course) + - [Learn You a Haskell for Great Good!](http://learnyouahaskell.com/) (book) + - [Learn Haskell by building a blog generator](https://lhbg-book.link) (book) + +This is just the tip of the iceberg though: check [Documentation](https://www.haskell.org/documentation/) for the full list of learning resources. + +That is it, fellow Haskeller! Enjoy learning Haskell, do (not?) be lazy and see you in the community! diff --git a/site/index.html b/site/index.html index 0c6ec104..4237b3c9 100644 --- a/site/index.html +++ b/site/index.html @@ -27,7 +27,7 @@

Declarative, statically typed code.


- Get Haskell + GET STARTED

diff --git a/site/templates/nav.html b/site/templates/nav.html index 21176087..7b784fdf 100644 --- a/site/templates/nav.html +++ b/site/templates/nav.html @@ -8,6 +8,7 @@ From 0f0a7ca114eb97940db17a90687d21a5a46bf3c4 Mon Sep 17 00:00:00 2001 From: Martin Sosic Date: Mon, 30 Jan 2023 21:05:58 +0100 Subject: [PATCH 4/4] fix --- site/get-started.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/get-started.markdown b/site/get-started.markdown index c25b3efc..9bc9b911 100644 --- a/site/get-started.markdown +++ b/site/get-started.markdown @@ -102,7 +102,7 @@ Please look at my favorite odd numbers: [11,13,15,17,19] By participating in the Haskell community you be able to ask for help and learn about new developments in the Haskell ecosystem. Some of the most popular places to interact with the community are: - [Haskell Discourse](https://discourse.haskell.org/) - - [r/haskell](https://www.reddit.com/r/haskell/) + - [Haskell subreddit](https://www.reddit.com/r/haskell/) - [https://wiki.haskell.org/IRC_channel](https://wiki.haskell.org/IRC_channel) We recommend joining right now, and don't be shy to ask for help! Check [https://www.haskell.org/community](https://www.haskell.org/community) for a full list of resources relating to the Haskell community.