Difference between revisions of "User:Lenny222/Haskell explained to the busy"

From HaskellWiki
Jump to navigation Jump to search
m
Line 53: Line 53:
 
|-
 
|-
 
|What is the meaning of the '''double dash''' "'''--'''"?
 
|What is the meaning of the '''double dash''' "'''--'''"?
| "--" begins a single-line comment. The rest of the line will be ignored.
+
| "--" begins a single-line comment. The rest of the line will be ignored by the compiler.
 
For example:
 
For example:
<haskell>-- sort the list
+
<haskell>-- Sort the list
 
sort [3,2,4]
 
sort [3,2,4]
 
</haskell>
 
</haskell>
 
or
 
or
<haskell>sort [3,2,4] -- sort the list</haskell>
+
<haskell>sort [3,2,4] -- Sort the list</haskell>
  +
|-
  +
|What is the meaning of "'''{-'''" and "'''-}'''"?
  +
|"{-" and "-}" define a block comment. Everything in between will be ignored by the compiler.
  +
For example:
  +
<haskell>
  +
{-
  +
The next line would sort the list, if it wasn't in a block comment
  +
sort [3,2,4]
  +
-}
  +
</haskell>
 
|-
 
|-
 
|What is the meaning of the '''dollar''' sign "'''$'''"?
 
|What is the meaning of the '''dollar''' sign "'''$'''"?

Revision as of 07:51, 1 October 2009

You have heard about Haskell but don't have the time to find out what it is?

This page may be for you.

Introduction

Question Answer
What is Haskell? Haskell is a purely functional, lazy, statically typed programming language
What is a purely functional programming language? TODO
What is good about a purely functional programming language? TODO
What is a lazy programming language? TODO
What is good about a lazy programming language? TODO
What is a statically typed programming language? TODO
What is good about a statically typed programming language? TODO
Is Haskell Open Source? TODO
Why the name "Haskell"? Haskell is named after the American mathematician Haskell Curry

Basics

Question Answer
How do you define a function in Haskell? TODO

For example:

add x y = x + y
Didn't you say Haskell is statically typed? It is. TODO
What is the meaning of the double dash "--"? "--" begins a single-line comment. The rest of the line will be ignored by the compiler.

For example:

-- Sort the list
sort [3,2,4]

or

sort [3,2,4] -- Sort the list
What is the meaning of "{-" and "-}"? "{-" and "-}" define a block comment. Everything in between will be ignored by the compiler.

For example:

{-
The next line would sort the list, if it wasn't in a block comment
sort [3,2,4]
-}
What is the meaning of the dollar sign "$"? "$" is a way to compose functions, but avoid typing too many brackets.

For example:

foo x = h (g (f x))

is the same as

foo x = h $ g $ f x
What is the meaning of the dot "."? "." is used to compose functions in point-free style, similar to "$".

For example:

foo x = h $ g $ f x

is the same as

foo = h . g . f
What is point-free style? Point-free style is a way to define functions solely as a composition of other functions, leaving out arguments in the definition.

For example:

takeFive x = take 5 x

is the same as

takeFive = take 5

in point-free style.

What is the meaning of "data"? TODO
What is the meaning of "newtype"? TODO
What is the meaning of "type"? TODO
What is currying? TODO
What is pattern matching? TODO

Advanced

Question Answer
What is a Monad? TODO
What is the meaning of "forall"? TODO