Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added get-started page. #227

Merged
merged 4 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions site/css/hl.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 7 additions & 0 deletions site/downloads.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ page: downloads
isDownloads: true
---

<div class="bs-callout bs-callout-info" style="padding: 0px 0px 10px 20px">
<p>
<h4>Psssst!</h4>
Looking to get started with Haskell? If so, check out the [Get Started](/get-started) page!
</p>
</div>

# Downloads

## Recommended installation instructions
Expand Down
118 changes: 118 additions & 0 deletions site/get-started.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
title: Get Started
page: get-started
isGettingStarted: true
---

# Get started

Welcome, new Haskeller! Read on to quickly set up your Haskell development environment, execute your first lines of code, and get directions for further learning.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the phrasing here. "Welcome, new Haskller!" is a great intro.


## Content
- [Set up a Haskell development environment](#set-up-a-haskell-development-environment)
- [GHCup: universal installer](#ghcup-universal-installer)
- [Editor](#editor)
- [Running your first lines of code](#running-your-first-lines-of-code)
- [Writing your first Haskell program](#writing-your-first-haskell-program)
- [Participate in the community](#participate-in-the-community)
- [Next steps](#next-steps)

## Set up a Haskell development environment

A complete Haskell development environment consists of the Haskell toolchain (compiler, language server, build tool) and an editor with good Haskell support. The quickest way to get this set up is to:

1. Use **GHCup** to install and manage the Haskell toolchain.
2. Use [**VSCode**](https://code.visualstudio.com/) as the editor, with the Haskell extension installed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you feel about linking to the free VSCodium builds instead of the non-free version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the motivation, but I don't think that is beneficial for the goal of reducing friction to get new people to learn Haskell. Those that care about open source will probably reach out vscodium anyway, while for those that don't, this probably isn't the best moment to introduce it -> we are already introducing Haskell which is complex enough.

If this will be a stopper for merging, I can change it to VSCodium, but I think it sends the wrong message to newcomers to Haskell.


### GHCup: universal installer

[GHCup](https://www.haskell.org/ghcup/#) is a universal installer for Haskell that will install everything you need to program in Haskell, and will help you manage those installations (update, switch versions, ...). Follow the instructions on the [GHCup webpage](https://www.haskell.org/ghcup/#) to install GHCup. Then use it to install the Haskell toolchain, which consists of:

1. **GHC** (The Haskell compiler) We will use GHC below to run our examples, but in practice you will mostly use a tool like Cabal or Stack to build your code, instead of GHC directly.
2. **HLS** (The Haskell Language Server) You won't use HLS directly, instead your code editor will use it in the background to provide you with a great experience while editing Haskell code.
3. **Cabal** (A Haskell build tool) You will use Cabal to structure your Haskell projects, build them, run them, define dependencies, ... .
4. **Stack** (A Haskell build tool) An alternative to Cabal.


<div class="bs-callout bs-callout-info">
<p>
<h4>Cabal and Stack: which one should I install?</h4>
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 a tutorial or book you can use whatever they recommend.
</p>
</div>

### Editor
[**Visual Studio Code**](https://code.visualstudio.com/) ([**VSCode**](https://code.visualstudio.com/)) is a popular choice with well-supported Haskell 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 your first lines of code
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could bring the interactive tutorial over from the main page to here to make some of this a bit more interactive?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's probably worth delaying to a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is interesting idea! I was considering a bit what to do with it, since it feels like right now we have two CTAs on landing page -> one is "Get Started" button, second is "Try it" prompt. Ideally there would be just one. But, if we would try to include it in the get-started page, I think it would side track us -> on get-started we are getting them to install tooling, and then we want them to use what they installed and try haskell through that, so when they are done with the get-started page, they have everything installed and have an idea how to use it -> they now feel ready to play with Haskell on their machine and had their first victory.

So at the moment I don't have a good idea how to plug in Try It into get-started. One option might be to remove it from landing page, but that does feel a bit bad since it is so cool. So I would probably just leave it for the time being, I don't think it hurts.


We have everything set up, let's use it! The Haskell compiler, GHC, comes with an interactive interpreter called GHCi which is great for playing with Haskell and trying things out, so let's give it a spin. Run `ghci` at your command prompt, which will start a new GHCi 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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just nit-picking here, but it's unusual for .hs file titles to not be capitalized.

Copy link

@lsmor lsmor Jan 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaronallen8455 Actually, the GHC guide uses the same example: hello.hs

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and I understand why - so that the resulting executable has the desired name. It just bothers me slightly that it diverges from the conventional naming pattern for .hs files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd see more lowercase .hs files if Haskell were a bit more convenient for scripting :). I've written a few scripts in Haskell with #!/usr/bin/env runhaskell and it seemed natural to give them lowercase names.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do whatever you like here, I don't mind. I think hello.hs is ok for this quick guide, they will learn soon anyway more about Haskell, I don't thikn this will give them some wrong ideas.
I also write scripts in haskell with lower name, when I am interpreting them with cabal or just with ghci and they are not part of any project, and this is such instance, so that is also a good argument for lower name yes.

```hs
main = do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
main = do
main :: IO ()
main = do

Not only is it best practice to give type signatures to top level bindings, but I feel like types should make an appearance somehow, since it's such a core part of the language.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good point, but I don't think :: IO () will mean much to them at this point. If it was myNumber :: Int, I think they could grok what it is, but I don't think IO () would mean anything at all. And the point is to just get them interested and get something running, they will learn proper stuff after this guide.

So I am soemwhat for showing off types, if we can do it in an easy way, but I don't think this example with IO would fall under that.

putStrLn "Hello, everybody!"
putStrLn ("Please look at my favorite odd numbers: " ++ show (filter odd [10..20]))
```

You can now compile it with `ghc` to produce an executable called `hello` 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!

**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]
```

## Participate in the community

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/)
- [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.

## Next steps
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure about this particular list of resources, but I like the general idea of picking a couple of free resources as a starting point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can discuss it, we had a bit of conversation on it here on the PR and ended up with this. I am big fan of LYAH (even though it is somewhat outdated), and also like the new book with building static blog generator, think they are very accessible and practical. I don't know much about the materials from the uni that we listed but they were on top of course list of Documentation page on haskell.org .
We can modify this if you have better ideas!


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 a bigger list of learning resources. That is it, fellow Haskeller! Enjoy learning Haskell, do (not?) be lazy and see you in the community!
2 changes: 1 addition & 1 deletion site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h4 class="tag">Declarative, statically typed code.</h4>
<div class="span12 col-sm-12" style="padding-top: 10px;">
<br/>
<p class="text-center">
<a href="/downloads/" class="btn btn-lg btn-primary" style="font-size: 1.5em">Get Haskell</a>
<a href="/get-started/" class="btn btn-lg btn-primary" style="font-size: 1.5em">Get started</a>
</p>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions site/templates/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</div>
<div id="haskell-menu" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li $if(isGetStarted)$ class="active" $endif$ ><a href="/get-started/">Get started</a></li>
<li $if(isDownloads)$ class="active" $endif$ ><a href="/downloads/">Downloads</a></li>
<li $if(isCommunity)$ class="active" $endif$ ><a href="/community/">Community</a></li>
<li $if(isDocumentation)$ class="active" $endif$ ><a href="/documentation/">Documentation</a></li>
Expand Down