Skip to content

Commit 6fa13d2

Browse files
Hotfix and minor improvements
1 parent 46f6acd commit 6fa13d2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tutorials/02_functions-types.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ Declaration of a function is simple, just use the prefix notation as you would c
7272
fibonacci :: Word -> Integer
7373
fibonacci 0 = 1
7474
fibonacci 1 = 1
75-
fibonacci n = (fibonacci n-1) + (fibonacci n-2)
75+
fibonacci n = fibonacci (n-1) + fibonacci (n-2)
7676
```
7777

7878
### Type declaration
7979

8080
There are three basic ways how to introduce your own data type:
8181

82-
1. type synonym = you just use a different name for some existing type (for example `String` is type synonym for `[Char]` = list of `Char`)
83-
2. new data type = declare type with type constructor (before `=`) and one or more data constructors (after `=`, separated by `|`), you may use typeclass constraints, type variables, and recursion
84-
3. newtype = new data type with exactly one data constructor with one parameter (new type is isomorphic with the "wrapped" type and compiler can do optimizations, can be used also in another way in more advanced code)
82+
1. `type` synonym = you just use a different name for some existing type (for example `String` is type synonym for `[Char]` = list of `Char`)
83+
2. new `data` type = declare type with type constructor (before `=`) and one or more data constructors (after `=`, separated by `|`), you may use typeclass constraints, type variables, and recursion
84+
3. `newtype` = new data type with exactly one data constructor with one parameter (new type is isomorphic with the "wrapped" type and compiler can do optimizations, can be used also in another way in more advanced code)
8585

8686
```haskell
8787
type String = [Char]
@@ -125,7 +125,7 @@ Haskell has a strong static type system which is one of the things making it so
125125
* `Word` = Unsigned integral number (same size as `Int`)
126126
* `Char` = Unicode character (ISO/IEC 10646)
127127
* `Bool` = truth value, only `True` or `False`
128-
* `String` = literally list of characters
128+
* `String` = literally list of characters (type synonym for `[Char]`)
129129

130130
### Type and data constructor
131131

@@ -288,7 +288,7 @@ myFunc (a, b, c, d) = (if d then a + d else a - d, b)
288288

289289
There are basic functions for tuples with two elements: `fst`, `snd`, and `swap`.
290290

291-
```
291+
```haskell
292292
Prelude> :type fst
293293
fst :: (a, b) -> a
294294
Prelude> fst (7, "Hello")

0 commit comments

Comments
 (0)