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

Replace existing hello world and quicksort snippets #708

Closed
petertseng opened this Issue Aug 15, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@petertseng
Copy link
Member

petertseng commented Aug 15, 2018

Currently, the https://github.com/exercism/haskell/blob/master/docs/ABOUT.md has a quicksort code snippet, and the https://github.com/exercism/haskell/blob/master/docs/SNIPPET.txt has hello-world

However

  • code examples should be removed from the about page, because #686
  • hello-world doesn't seem like an interesting enough example
  • the quicksort does not display properly on the website because of #693 (this problem has been fixed)

Your task is to find a new snippet that is suitably representative of the language. The limits imposed in https://github.com/exercism/docs/blob/master/language-tracks/documentation/introductory-copy.md are a 10 line maximum length and a 40 character maximum width.

When you find one, you should:

@2mol

This comment has been minimized.

Copy link

2mol commented Aug 27, 2018

I started thinking about this. I would like opinions on the following classic for a code snippet:

fib :: [Int]
fib = 0:1:zipWith (+) fib (tail fib)

I love this one, but I'm a bit torn on the question if it's the right snippet to choose.

Cons:

  • It is very 'clever', so it might feel more like a trick than a good representation of beginner haskell code.
  • It is not obvious if you don't know a smidge of functional programming and the fact that laziness exists.
  • It's too short.

Pros:

  • It clever and really cool, therefore it could spark the interest of a certain subset of people that Haskell attracts anyway, e.g people interested in abstractions and mathematical elegance. It has the kind of wow-factor that made me realize Haskell is utterly different from anything I knew at that point.

I will continue looking for other good short snippets, so far I haven't found the perfect one yet. I quite like the Python one for example, because it communicates usefulness and beginner-friendliness, while being a good deal less trivial than Hello-World.

@petertseng

This comment has been minimized.

Copy link
Member

petertseng commented Aug 31, 2018

Cons:

  • It is very 'clever', so it might feel more like a trick than a good representation of beginner haskell code.
  • It is not obvious if you don't know a smidge of functional programming and the fact that laziness exists.
  • It's too short.

I acknowledge these as true, and I think they can be addressed by adding some explanatory comments to the code, and an example of how you would use fib after having defined it. The comments might explain that we are defining the Fibonacci sequence, and call special attention to the fact that it is defined in terms of itself, and thus this list is infinite.
Then, perhaps one might show a take 10 fib and comment that this produces the first ten: [0,1,1,2,3,5,8,13,21,34] (or whatever fits in the 40 column limit)

Pros:

  • It clever and really cool, therefore it could spark the interest of a certain subset of people that Haskell attracts anyway, e.g people interested in abstractions and mathematical elegance. It has the kind of wow-factor that made me realize Haskell is utterly different from anything I knew at that point.

I agree that it is interesting to expose the new way of looking at things.

continue looking for other good short snippets, so far I haven't found the perfect one yet

Other ideas for possible places to find:

I would wonder if https://wiki.haskell.org/Example_code has something, but not all of the examples there are optimised for the use case and requirements here (short, but give a taste of the language). There may be some out there, just don't know about them. https://rosettacode.org/wiki/Category:Haskell is a big list, but it is probably too big to go through quickly and find a suitable.

Since this snippet's purpose is to provide an introduction, I had an idea of searching for "introduction to Haskell" and found pages like https://www.schoolofhaskell.com/school/starting-with-haskell/introduction-to-haskell/1-haskell-basics . I wonder if there's anything there.

sshine added a commit to sshine/exercism-haskell that referenced this issue Sep 12, 2018

Fix code snippets in ABOUT.md and SNIPPET.txt (fixes exercism#708)
This commit strictly

 - Removes the Quicksort code example from ABOUT.md as exercism#686 dictates.
 - Adds a real-world web-server example (Scotty) within 38x9 characters.

sshine added a commit to sshine/exercism-haskell that referenced this issue Sep 12, 2018

Fix code snippets in ABOUT.md and SNIPPET.txt (fixes exercism#708)
This commit

 - Removes the Quicksort code example from ABOUT.md as exercism#686 dictates.
 - Adds a real-world web-server example (Scotty) within 38x9 characters.
 - Removes the sentence "Haskell syntax is beautiful and minimal."
   because it tied to the code snippet, not because it isn't true. ;-)

sshine added a commit to sshine/exercism-haskell that referenced this issue Sep 12, 2018

Fix code snippets in ABOUT.md and SNIPPET.txt (fixes exercism#708)
This commit

 - Removes the Quicksort code example from ABOUT.md as exercism#686 dictates.
 - Adds a real-world web-server example (Scotty) within 38x9 characters.
 - Removes the sentence "Haskell syntax is beautiful and minimal."
   because it tied to the code snippet, not because it isn't true. ;-)
@sshine

This comment has been minimized.

Copy link
Contributor

sshine commented Sep 12, 2018

I'm sorry for spamming. I thought references to issues wouldn't propagate before making a PR.

petertseng added a commit that referenced this issue Sep 12, 2018

Fix code snippets in ABOUT.md and SNIPPET.txt (fixes #708) (#719)
This commit

 - Removes the Quicksort code example from ABOUT.md as #686 dictates.
 - Adds a real-world web-server example (Scotty) within 38x9 characters.
 - Removes the sentence "Haskell syntax is beautiful and minimal."
   because it tied to the code snippet, not because it isn't true. ;-)

The snippet comes from http://hackage.haskell.org/package/scotty-0.11.2
@petertseng

This comment has been minimized.

Copy link
Member

petertseng commented Sep 12, 2018

While the issue was closed because of a snippet being submitted, please feel free to continue discussing possible snippets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment