You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/01_fp-env.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -200,7 +200,7 @@ We can read this as: the expression `"Hello"` is of type `String` (`::` means "*
200
200
201
201
This is the first math connection worth making explicit:
202
202
* In mathematics, we say that an object has a certain type or belongs to a certain set, e.g., `5 ∈ ℤ` (alt. `5 : ℤ`) means that the number `5` is an integer.
203
-
* In Haskell, we say that an expression has a certain type, e.g., `5 :: Int` means that the expression `5` is of type `Int`.
203
+
* In Haskell, we say that an expression has a certain type, e.g., `5::Int` means that the expression `5` is of type `Int`.
204
204
205
205
Types are not decoration — they are part of the meaning of the program. The type system helps ensure correctness, guides program structure, and enables powerful abstractions. **Type inference** means that you often do not need to write types explicitly; GHC can figure them out for you. It does so by analyzing how expressions are constructed and combined. It always tries to find the most general type that fits the expression.
Copy file name to clipboardExpand all lines: tutorials/03_branching.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -304,13 +304,13 @@ It is important to distinguish between:
304
304
*`otherwise` – a `Bool` expression equal to `True`
305
305
306
306
```
307
-
Prelude> :t otherwise
308
-
Prelude> otherwise == True
307
+
ghci> :t otherwise
308
+
ghci> otherwise == True
309
309
True
310
-
Prelude> not otherwise
310
+
ghci> not otherwise
311
311
False
312
312
otherwise :: Bool
313
-
Prelude> :t _
313
+
ghci> :t _
314
314
315
315
<interactive>:1:1: error:
316
316
• Found hole: _ :: t
@@ -621,7 +621,7 @@ Only the arguments that are actually used are evaluated. This is a direct conseq
621
621
622
622
Some operations cannot proceed without actual values. For example, arithmetic requires its arguments to be evaluated:
623
623
624
-
Prelude> 3 + undefined
624
+
ghci> 3 + undefined
625
625
*** Exception: Prelude.undefined
626
626
627
627
This does not contradict laziness — it simply means the *value is now required*. Laziness delays evaluation, but it does not eliminate it.
@@ -914,7 +914,7 @@ T.unpack :: Text -> String
914
914
Example:
915
915
916
916
```
917
-
Prelude> import qualified Data.Text as T
917
+
ghci> import qualified Data.Text as T
918
918
919
919
Prelude T> txt = T.pack "my effective text"
920
920
@@ -961,14 +961,14 @@ It is commonly used for:
961
961
Example:
962
962
963
963
```
964
-
Prelude> import qualified Data.ByteString as B
964
+
ghci> import qualified Data.ByteString as B
965
965
966
-
Prelude> bstr = B.pack [97, 98, 99]
966
+
ghci> bstr = B.pack [97, 98, 99]
967
967
968
-
Prelude> bstr
968
+
ghci> bstr
969
969
"abc"
970
970
971
-
Prelude> B.index bstr 2
971
+
ghci> B.index bstr 2
972
972
99
973
973
```
974
974
@@ -982,10 +982,10 @@ For ASCII-based text, there is a convenient variant [Data.ByteString.Char8](http
982
982
importqualifiedData.ByteString.Char8asC
983
983
```
984
984
```
985
-
Prelude> C.pack "abc"
985
+
ghci> C.pack "abc"
986
986
"abc"
987
987
988
-
Prelude> C.index (C.pack "abc") 2
988
+
ghci> C.index (C.pack "abc") 2
989
989
'c'
990
990
```
991
991
@@ -1000,7 +1000,7 @@ import qualified Data.Text.Encoding as E
1000
1000
```
1001
1001
1002
1002
```
1003
-
Prelude> E.encodeUtf8 (T.pack "život, жизнь, lífið")
1003
+
ghci> E.encodeUtf8 (T.pack "život, жизнь, lífið")
1004
1004
```
1005
1005
1006
1006
Encoding makes it explicit:
@@ -1029,16 +1029,16 @@ or in GHCi:
1029
1029
Now *string literals become polymorphic*:
1030
1030
1031
1031
```
1032
-
Prelude> :type "abc"
1032
+
ghci> :type "abc"
1033
1033
"abc" :: IsString p => p
1034
1034
```
1035
1035
1036
1036
This allows code like the following, without explicit `pack`:
1037
1037
1038
1038
```
1039
-
Prelude> import qualified Data.Text as T
1039
+
ghci> import qualified Data.Text as T
1040
1040
1041
-
Prelude> T.length "abc"
1041
+
ghci> T.length "abc"
1042
1042
3
1043
1043
```
1044
1044
@@ -1054,7 +1054,7 @@ You can always convert between them when needed and sometimes your choice will d
1054
1054
1055
1055
## Task assignment
1056
1056
1057
-
For the second assignment, navigate to the `hw03` project and follow the instructions in the `README.md` file there. It will test your skills in branching, local definitions, and working with modules.
1057
+
For the assignment, navigate to the `hw03` project and follow the instructions in the `README.md` file there. It will test your skills in branching, local definitions, and working with modules.
0 commit comments