Justin Bailey | 11 Oct 01:06
Picon

[ANN] Haskell Cheatsheet v1.0

All,

I've created a "cheat sheet" for Haskell. It's a PDF that tries to
summarize Haskell 98's syntax, keywords and other language elements.
It's currently available on hackage[1]. Once downloaded, unpack the
archive and you'll see the PDF. A literate source file is also
included.

If you install with "cabal install cheatsheet", run "cheatsheet"
afterwards and the program will tell you where the PDF is located.

The audience for this document is beginning to intermediate Haskell
programmers. I found it difficult to look up some of the less-used
syntax and other language stumbling blocks as I learned Haskell over
the last few years, so I hope this document can help others in the
future.

This is a beta release (which is why I've limited the audience by
using hackage) to get feedback before distributing the PDF to a wider
audience. With that in mind, I welcome your comments or patches[2].

Justin

[1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/CheatSheet
[2] git://github.com/m4dc4p/cheatsheet.git
Adrian Neumann | 11 Oct 07:59
Picon
Picon

Re: [ANN] Haskell Cheatsheet v1.0

Thank you for your work! I just glanced over it but I'll suggest it  
to be linked to from the homepage of my university's functional  
programming course.
However, thirteen pages can hardly be called "cheatsheet". It's more  
like a quick reference.

You could add [100,99..] "infinite liste of numbers from 100  
downwards" to you "numbers" section, as it is an example where the  
range does go backward.

Adrian

Am 11.10.2008 um 01:08 schrieb Justin Bailey:

> All,
>
> I've created a "cheat sheet" for Haskell. It's a PDF that tries to
> summarize Haskell 98's syntax, keywords and other language elements.
> It's currently available on hackage[1]. Once downloaded, unpack the
> archive and you'll see the PDF. A literate source file is also
> included.
>
> If you install with "cabal install cheatsheet", run "cheatsheet"
> afterwards and the program will tell you where the PDF is located.
>
> The audience for this document is beginning to intermediate Haskell
> programmers. I found it difficult to look up some of the less-used
> syntax and other language stumbling blocks as I learned Haskell over
> the last few years, so I hope this document can help others in the
> future.
(Continue reading)

Thomas Hartman | 11 Oct 13:33
Picon

Re: [ANN] Haskell Cheatsheet v1.0

Very nice!

I have my own cheat list, which are haskell commands I find useful but
find inconvenient or difficult to look up in the supplied
documentation. I actually hardwire my cheats into .bashrc doing
something like

thartman_haskell_cheatting() {

cat << EOF
  blah blah
cheat

}

so i can quickly see all my haskell cheats using tab completion. but a
pdf is even nicer :)

**************************

thartman <at> thartman-laptop:~/Desktop>thartman_haskell_oneliners
  ghc -e '1+2'

thartman <at> thartman-laptop:~/Desktop>thartman_haskell_regex_hints
  cabal install pcre-regex

  Most likely want:

  Prelude Text.Regex.PCRE> "user123" =~ "^(user)(\d*)$" ::
(String,String,String,[String])
(Continue reading)

Justin Bailey | 12 Oct 00:31
Picon

Re: [ANN] Haskell Cheatsheet v1.0

Thanks to everyone for their feedback. I've made some updates and
posted the PDF to my blog:

  http://blog.codeslower.com/2008/10/The-Haskell-Cheatsheet

On Sat, Oct 11, 2008 at 4:33 AM, Thomas Hartman <tphyahoo <at> gmail.com> wrote:
> Very nice!
>
> I have my own cheat list, which are haskell commands I find useful but
> find inconvenient or difficult to look up in the supplied
> documentation. I actually hardwire my cheats into .bashrc doing
> something like
>
> thartman_haskell_cheatting() {
>
> cat << EOF
>  blah blah
> cheat
>
> }
>
> so i can quickly see all my haskell cheats using tab completion. but a
> pdf is even nicer :)
>
> **************************
>
> thartman <at> thartman-laptop:~/Desktop>thartman_haskell_oneliners
>  ghc -e '1+2'
>
> thartman <at> thartman-laptop:~/Desktop>thartman_haskell_regex_hints
(Continue reading)

Andrew Coppin | 12 Oct 10:57

Re: [ANN] Haskell Cheatsheet v1.0

Justin Bailey wrote:
> Thanks to everyone for their feedback. I've made some updates and
> posted the PDF to my blog:
>
>   http://blog.codeslower.com/2008/10/The-Haskell-Cheatsheet
>   

I was wondering why there isn't a PDF directly downloadable anywhere... ;-)

FWIW, I just learned something by looking at this. I was under the 
impression that a literal number can have *any* type, and therefore "1" 
and "1.0" are completely equivilent. Apparently this is untrue. (!)

Your "numbers" section is actually mostly list comprehensions. While 
it's interesting that you need a space between ".." and "-" for negative 
numbers, this wasn't immediately clear from reading your text. Maybe it 
would be better to write that as a sentence? (Or just format the correct 
syntax in monotype so the space is more obvious.)
Holger Siegel | 11 Oct 14:30
Picon

Re: [ANN] Haskell Cheatsheet v1.0

On Saturday 11 October 2008 01:08:15 Justin Bailey wrote:

> This is a beta release (which is why I've limited the audience by
> using hackage) to get feedback before distributing the PDF to a wider
> audience. With that in mind, I welcome your comments or patches[2].
>
> Justin
>
> [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/CheatSheet
> [2] git://github.com/m4dc4p/cheatsheet.git

Looks good!

Some minor issues:

- sometimes it is a bit verbose for a cheatsheet; for example the reference to 
language C in the section about the layout rule.

- in the section about strings, you give an example of a syntax error; it 
would be sufficient to show what is right.

- in the section about operator precedence you define 'div1' to be right 
associative. Instead, you could show where right associativity is actually 
useful (>>=, ...).

- The explanation of the layout rule is wrong. If you define more than one 
value in a let declaration, then it is only required that the identifiers  
start on the same column.

- When I started to learn Haskell, I had problems with the use of (.) and ($). 
(Continue reading)

Justin Bailey | 12 Oct 00:32
Picon

Re: [ANN] Haskell Cheatsheet v1.0

On Sat, Oct 11, 2008 at 5:30 AM, Holger Siegel <holgersiegel74 <at> yahoo.de> wrote:
>
> - The explanation of the layout rule is wrong. If you define more than one
> value in a let declaration, then it is only required that the identifiers
> start on the same column.

Thank you - updated.

>
> - When I started to learn Haskell, I had problems with the use of (.) and ($).
> I had learned what function application and lambda abstractions look like, but
> then I looked at Haskell code written by experienced Haskellers and found
> expressions like (map (succ . succ) $  1:xs) that I did not understand.
> A small section describing how to read such expressions could be useful for
> beginners.

Me too. I had a section on that originally but cut it due to time.
Patches are always welcome :)

>
> - the section about do-notation is more a mini-tutorial than a cheatsheet.
> Instead, you could show two or three examples that demonstrate how do-
> notation, list comprehensions and the operator >>= relate. That is what I had
> to look up more than once until I got used to it. There is also an example of
> what is wrong, where showing the right thing would have sufficed.
>

True, but I think it's helpful. That stuff really confused me at first.

Justin
(Continue reading)

Dino Morelli | 11 Oct 15:43

Re: [ANN] Haskell Cheatsheet v1.0

On Fri, 10 Oct 2008, Justin Bailey wrote:

> I've created a "cheat sheet" for Haskell. It's a PDF that tries to
> summarize Haskell 98's syntax, keywords and other language elements.
> It's currently available on hackage[1]. Once downloaded, unpack the
> archive and you'll see the PDF. A literate source file is also
> included.
>
..
> The audience for this document is beginning to intermediate Haskell
> programmers. I found it difficult to look up some of the less-used
> syntax and other language stumbling blocks as I learned Haskell over
> the last few years, so I hope this document can help others in the
> future.
>
..
> Justin
>
> [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/CheatSheet
> [2] git://github.com/m4dc4p/cheatsheet.git
> _______________________________________________

Justin (and everyone now contributing to this), thanks. This type of
thing is very helpful. There is a well-known one-page cheat-sheet like
this for Perl5 (and a newer one for Perl6 too). You can see it by typing
`perldoc perlcheat` on a system with Perl.

I wonder if we don't need something like that.

On a related note, I had come up with this short list to help with how
(Continue reading)

Stephen Hicks | 11 Oct 18:33
Picon
Favicon

Re: [ANN] Haskell Cheatsheet v1.0

On Fri, Oct 10, 2008 at 7:08 PM, Justin Bailey <jgbailey <at> gmail.com> wrote:
> I've created a "cheat sheet" for Haskell. It's a PDF that tries to
> summarize Haskell 98's syntax, keywords and other language elements.
> It's currently available on hackage[1]. Once downloaded, unpack the
> archive and you'll see the PDF. A literate source file is also
> included.

It looks very nice, if a bit verbose.  One minor comment is that on
page 4 you give a "type signature" for if-then-else.  I would contend
that it should be Bool -> a -> a -> a, instead.

steve
Kurt Hutchinson | 14 Oct 18:09
Picon

Re: [ANN] Haskell Cheatsheet v1.0

On Fri, Oct 10, 2008 at 7:08 PM, Justin Bailey <jgbailey <at> gmail.com> wrote:
> This is a beta release (which is why I've limited the audience by
> using hackage) to get feedback before distributing the PDF to a wider
> audience. With that in mind, I welcome your comments or patches[2].

On page 1, you list 'return' as a reserved word, but it isn't. It's
just a function, and in fact you can redefine it.

Gmane