Skip to content

Commit 7d0d98c

Browse files
Matthijsulysses4ever
authored andcommitted
GHCI -> GHCi
1 parent b7c7066 commit 7d0d98c

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

source_md/functors-applicative-functors-and-monoids.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ So `a -> b -> c` can be written as `a -> (b -> c)`, to make the currying more ap
223223
In the same vein, if we write `fmap :: (a -> b) -> (f a -> f b)`, we can think of `fmap` not as a function that takes one function and a functor and returns a functor, but as a function that takes a function and returns a new function that's just like the old one, only it takes a functor as a parameter and returns a functor as the result.
224224
It takes an `a -> b` function and returns a function `f a -> f b`.
225225
This is called *lifting* a function.
226-
Let's play around with that idea by using GHCI's `:t` command:
226+
Let's play around with that idea by using GHCi's `:t` command:
227227

228228
```{.haskell:hs}
229229
ghci> :t fmap (*2)
@@ -241,7 +241,7 @@ When we say *a functor over numbers*, you can think of that as *a functor that h
241241
The former is a bit fancier and more technically correct, but the latter is usually easier to get.
242242
:::
243243

244-
This is even more apparent if we partially apply, say, `fmap (++"!")` and then bind it to a name in GHCI.
244+
This is even more apparent if we partially apply, say, `fmap (++"!")` and then bind it to a name in GHCi.
245245

246246
You can think of `fmap` as either a function that takes a function and a functor and then maps that function over the functor, or you can think of it as a function that takes a function and lifts that function so that it operates on functors.
247247
Both views are correct and in Haskell, equivalent.

source_md/higher-order-functions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ From the definition of sections, `(-4)` would result in a function that takes a
130130
However, for convenience, `(-4)` means minus four.
131131
So if you want to make a function that subtracts 4 from the number it gets as a parameter, partially apply the `subtract` function like so: `(subtract 4)`.
132132

133-
What happens if we try to just do `multThree 3 4` in GHCI instead of binding it to a name with a *let* or passing it to another function?
133+
What happens if we try to just do `multThree 3 4` in GHCi instead of binding it to a name with a *let* or passing it to another function?
134134

135135
```{.haskell:hs}
136136
ghci> multThree 3 4
@@ -140,9 +140,9 @@ ghci> multThree 3 4
140140
• In a stmt of an interactive GHCi command: print it
141141
```
142142

143-
GHCI is telling us that the expression produced a function of type `a -> a` but it doesn't know how to print it to the screen.
143+
GHCi is telling us that the expression produced a function of type `a -> a` but it doesn't know how to print it to the screen.
144144
Functions aren't instances of the `Show` typeclass, so we can't get a neat string representation of a function.
145-
When we do, say, `1 + 1` at the GHCI prompt, it first calculates that to `2` and then calls `show` on `2` to get a textual representation of that number.
145+
When we do, say, `1 + 1` at the GHCi prompt, it first calculates that to `2` and then calls `show` on `2` to get a textual representation of that number.
146146
And the textual representation of `2` is just the string `"2"`, which then gets printed to our screen.
147147

148148
## Some higher-orderism is in order {#higher-orderism}
@@ -392,7 +392,7 @@ First, we'll begin by mapping the `(^2)` function to the infinite list `[1..]`.
392392
Then we filter them so we only get the odd ones.
393393
And then, we'll take elements from that list while they are smaller than 10,000.
394394
Finally, we'll get the sum of that list.
395-
We don't even have to define a function for that, we can do it in one line in GHCI:
395+
We don't even have to define a function for that, we can do it in one line in GHCi:
396396

397397
```{.haskell:ghci}
398398
ghci> sum (takeWhile (<10000) (filter odd (map (^2) [1..])))

source_md/input-and-output.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ With those two parts separated, we can still reason about our pure program and t
2727

2828
![HELLO!](assets/images/input-and-output/helloworld.png){.left width=223 height=179}
2929

30-
Up until now, we've always loaded our functions into GHCI to test them out and play with them.
30+
Up until now, we've always loaded our functions into GHCi to test them out and play with them.
3131
We've also explored the standard library functions that way.
3232
But now, after eight or so chapters, we're finally going to write our first *real* Haskell program!
3333
Yay!
@@ -208,14 +208,14 @@ We can also use a *do* block to glue together a few I/O actions and then we can
208208
Either way, they'll be performed only if they eventually fall into `main`.
209209

210210
Oh, right, there's also one more case when I/O actions will be performed.
211-
When we type out an I/O action in GHCI and press return, it will be performed.
211+
When we type out an I/O action in GHCi and press return, it will be performed.
212212

213213
```{.haskell:hs}
214214
ghci> putStrLn "HEEY"
215215
HEEY
216216
```
217217

218-
Even when we just punch out a number or call a function in GHCI and press return, it will evaluate it (as much as it needs) and then call `show` on it and then it will print that string to the terminal using `putStrLn` implicitly.
218+
Even when we just punch out a number or call a function in GHCi and press return, it will evaluate it (as much as it needs) and then call `show` on it and then it will print that string to the terminal using `putStrLn` implicitly.
219219

220220
Remember *let* bindings?
221221
If you don't, refresh your memory on them by reading [this section](syntax-in-functions.html#let-it-be).
@@ -429,8 +429,8 @@ True
429429
```
430430

431431
As you can see, it's a very handy function.
432-
Remember how we talked about how I/O actions are performed only when they fall into `main` or when we try to evaluate them in the GHCI prompt?
433-
When we type out a value (like `3` or `[1,2,3]`) and press the return key, GHCI actually uses `print` on that value to display it on our terminal!
432+
Remember how we talked about how I/O actions are performed only when they fall into `main` or when we try to evaluate them in the GHCi prompt?
433+
When we type out a value (like `3` or `[1,2,3]`) and press the return key, GHCi actually uses `print` on that value to display it on our terminal!
434434

435435
```{.haskell:hs}
436436
ghci> 3
@@ -534,9 +534,9 @@ ghci> sequence (map print [1,2,3,4,5])
534534
```
535535

536536
What's with the `[(),(),(),(),()]` at the end?
537-
Well, when we evaluate an I/O action in GHCI, it's performed and then its result is printed out, unless that result is `()`, in which case it's not printed out.
538-
That's why evaluating `putStrLn "hehe"` in GHCI just prints out `hehe` (because the contained result in `putStrLn "hehe"` is `()`).
539-
But when we do `getLine` in GHCI, the result of that I/O action is printed out, because `getLine` has a type of `IO String`.
537+
Well, when we evaluate an I/O action in GHCi, it's performed and then its result is printed out, unless that result is `()`, in which case it's not printed out.
538+
That's why evaluating `putStrLn "hehe"` in GHCi just prints out `hehe` (because the contained result in `putStrLn "hehe"` is `()`).
539+
But when we do `getLine` in GHCi, the result of that I/O action is printed out, because `getLine` has a type of `IO String`.
540540

541541
Because mapping a function that returns an I/O action over a list and then sequencing it is so common, the utility functions `mapM`{.label .function} and `mapM_`{.label .function} were introduced.
542542
`mapM` takes a function and a list, maps the function over the list and then sequences it.
@@ -626,7 +626,7 @@ In this section, we learned the basics of input and output.
626626
We also found out what I/O actions are, how they enable us to do input and output and when they are actually performed.
627627
To reiterate, I/O actions are values much like any other value in Haskell.
628628
We can pass them as parameters to functions and functions can return I/O actions as results.
629-
What's special about them is that if they fall into the `main` function (or are the result in a GHCI line), they are performed.
629+
What's special about them is that if they fall into the `main` function (or are the result in a GHCi line), they are performed.
630630
And that's when they get to write stuff on your screen or play Yakety Sax through your speakers.
631631
Each I/O action can also encapsulate a result with which it tells you what it got from the real world.
632632

@@ -1920,7 +1920,7 @@ This is cool because it won't cause the memory usage to skyrocket and the 32 KiB
19201920

19211921
If you look through the [documentation](https://hackage.haskell.org/package/bytestring/docs/Data-ByteString-Lazy.html) for `Data.ByteString.Lazy`, you'll see that it has a lot of functions that have the same names as the ones from `Data.List`, only the type signatures have `ByteString` instead of `[a]` and `Word8` instead of `a` in them.
19221922
The functions with the same names mostly act the same as the ones that work on lists.
1923-
Because the names are the same, we're going to do a qualified import in a script and then load that script into GHCI to play with bytestrings.
1923+
Because the names are the same, we're going to do a qualified import in a script and then load that script into GHCi to play with bytestrings.
19241924

19251925
```{.haskell:hs}
19261926
import qualified Data.ByteString.Lazy as B

source_md/making-our-own-types-and-typeclasses.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ But this is just something to think about, because `==` will always have a type
14181418
:::
14191419

14201420
Ooh, one more thing, check this out!
1421-
If you want to see what the instances of a typeclass are, just do `:info YourTypeClass` in GHCI.
1421+
If you want to see what the instances of a typeclass are, just do `:info YourTypeClass` in GHCi.
14221422
So typing `:info Num` will show which functions the typeclass defines and it will give you a list of the types in the typeclass.
14231423
`:info` works for types and type constructors too.
14241424
If you do `:info Maybe`, it will show you all the typeclasses that `Maybe` is an instance of.
@@ -1753,7 +1753,7 @@ A kind is more or less the type of a type.
17531753
This may sound a bit weird and confusing, but it's actually a really cool concept.
17541754

17551755
What are kinds and what are they good for?
1756-
Well, let's examine the kind of a type by using the `:k` command in GHCI.
1756+
Well, let's examine the kind of a type by using the `:k` command in GHCi.
17571757

17581758
```{.haskell:hs}
17591759
ghci> :k Int
@@ -1902,7 +1902,7 @@ Well, we see it takes three type parameters, so it's going to be `something -> s
19021902
It's safe to say that `p` is a concrete type and thus has a kind of `*`.
19031903
For `k`, we assume `*` and so by extension, `t` has a kind of `* -> *`.
19041904
Now let's just replace those kinds with the *somethings* that we used as placeholders and we see it has a kind of `(* -> *) -> * -> * -> *`.
1905-
Let's check that with GHCI.
1905+
Let's check that with GHCi.
19061906

19071907
```{.haskell:hs}
19081908
ghci> :k Barry

source_md/modules.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ When you do `import Data.List`, all the functions that `Data.List` exports becom
3737
`nub` is a function defined in `Data.List` that takes a list and weeds out duplicate elements.
3838
Composing `length` and `nub` by doing `length . nub` produces a function that's the equivalent of `\xs -> length (nub xs)`.
3939

40-
You can also put the functions of modules into the global namespace when using GHCI.
41-
If you're in GHCI and you want to be able to call the functions exported by `Data.List`, do this:
40+
You can also put the functions of modules into the global namespace when using GHCi.
41+
If you're in GHCi and you want to be able to call the functions exported by `Data.List`, do this:
4242

4343
```{.haskell:ghci}
4444
ghci> :m + Data.List
4545
```
4646

47-
If we want to load up the names from several modules inside GHCI, we don't have to do `:m +` several times, we can just load up several modules at once.
47+
If we want to load up the names from several modules inside GHCi, we don't have to do `:m +` several times, we can just load up several modules at once.
4848

4949
```{.haskell:ghci}
5050
ghci> :m + Data.List Data.Map Data.Set
@@ -945,7 +945,7 @@ Because `Data.Map` exports functions that clash with the `Prelude` and `Data.Lis
945945
import qualified Data.Map as Map
946946
```
947947

948-
Put this import statement into a script and then load the script via GHCI.
948+
Put this import statement into a script and then load the script via GHCi.
949949

950950
Let's go ahead and see what `Data.Map` has in store for us!
951951
Here's the basic rundown of its functions.
@@ -1158,7 +1158,7 @@ Put this import statement in a script:
11581158
import qualified Data.Set as Set
11591159
```
11601160

1161-
And then load the script via GHCI.
1161+
And then load the script via GHCi.
11621162

11631163
Let's say we have two pieces of text.
11641164
We want to find out which characters were used in both of them.

source_md/starting-out.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ GHCi, version 9.2.4: https://www.haskell.org/ghc/ :? for help
1717
ghci>
1818
```
1919

20-
Congratulations, you're in GHCI!
20+
Congratulations, you're in GHCi!
2121

2222
Here's some simple arithmetic.
2323

@@ -50,7 +50,7 @@ Pretty cool, huh?
5050
Yeah, I know it's not but bear with me.
5151
A little pitfall to watch out for here is negating numbers.
5252
If we want to have a negative number, it's always best to surround it with parentheses.
53-
Doing `5 * -3` will make GHCI yell at you but doing `5 * (-3)` will work just fine.
53+
Doing `5 * -3` will make GHCi yell at you but doing `5 * (-3)` will work just fine.
5454

5555
Boolean algebra is also pretty straightforward.
5656
As you probably know, `&&` means a boolean *and*, `||` means a boolean *or*.
@@ -96,10 +96,10 @@ Well, if we try the first snippet, we get a big scary error message!
9696
```
9797

9898
Yikes!
99-
What GHCI is telling us here is that `"llama"` is not a number and so it doesn't know how to add it to 5.
99+
What GHCi is telling us here is that `"llama"` is not a number and so it doesn't know how to add it to 5.
100100
Even if it wasn't `"llama"` but `"four"` or `"4"`, Haskell still wouldn't consider it to be a number.
101101
`+` expects its left and right side to be numbers.
102-
If we tried to do `True == 5`, GHCI would tell us that the types don't match.
102+
If we tried to do `True == 5`, GHCi would tell us that the types don't match.
103103
Whereas `+` works only on things that are considered numbers, `==` works on any two things that can be compared.
104104
But the catch is that they both have to be the same type of thing.
105105
You can't compare apples and oranges.
@@ -189,7 +189,7 @@ The function name is followed by parameters separated by spaces.
189189
But when defining functions, there's a `=` and after that we define what the function does.
190190
Save this as `baby.hs` or something.
191191
Now navigate to where it's saved and run `ghci` from there.
192-
Once inside GHCI, do `:l baby`.
192+
Once inside GHCi, do `:l baby`.
193193
Now that our script is loaded, we can play with the function that we defined.
194194

195195
```{.haskell: .ghci}
@@ -211,7 +211,7 @@ doubleUs x y = x*2 + y*2
211211

212212
Simple.
213213
We could have also defined it as `doubleUs x y = x + x + y + y`.
214-
Testing it out produces pretty predictable results (remember to append this function to the `baby.hs` file, save it and then do `:l baby` inside GHCI).
214+
Testing it out produces pretty predictable results (remember to append this function to the `baby.hs` file, save it and then do `:l baby` inside GHCi).
215215

216216
```{.haskell: .ghci}
217217
ghci> doubleUs 4 9
@@ -761,7 +761,7 @@ ghci> [ [ x | x <- xs, even x ] | xs <- xxs]
761761
```
762762

763763
You can write list comprehensions across several lines.
764-
So if you're not in GHCI, it's better to split longer list comprehensions across multiple lines, especially if they're nested.
764+
So if you're not in GHCi, it's better to split longer list comprehensions across multiple lines, especially if they're nested.
765765

766766
## Tuples {#tuples}
767767

@@ -882,7 +882,7 @@ ghci> triangles = [ (a,b,c) | c <- [1..10], b <- [1..10], a <- [1..10] ]
882882
```
883883

884884
We're just drawing from three lists and our output function is combining them into a triple.
885-
If you evaluate that by typing out `triangles` in GHCI, you'll get a list of all possible triangles with sides under or equal to 10.
885+
If you evaluate that by typing out `triangles` in GHCi, you'll get a list of all possible triangles with sides under or equal to 10.
886886
Next, we'll add a condition that they all have to be right triangles.
887887
We'll also modify this function by taking into consideration that side b isn't larger than the hypotenuse and that side a isn't larger than side b.
888888

source_md/types-and-typeclasses.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ A type is a kind of label that every expression has.
2323
It tells us in which category of things that expression fits.
2424
The expression `True` is a boolean, `"hello"` is a string, etc.
2525

26-
Now we'll use GHCI to examine the types of some expressions.
26+
Now we'll use GHCi to examine the types of some expressions.
2727
We'll do that by using the `:t` command which, followed by any valid expression, tells us its type.
2828
Let's give it a whirl.
2929

@@ -303,9 +303,9 @@ ghci> read "4"
303303
Probable fix: add a type signature that fixes these type variable(s)
304304
```
305305

306-
What GHCI is telling us here is that it doesn't know what we want in return.
306+
What GHCi is telling us here is that it doesn't know what we want in return.
307307
Notice that in the previous uses of `read` we did something with the result afterwards.
308-
That way, GHCI could infer what kind of result we wanted out of our `read`.
308+
That way, GHCi could infer what kind of result we wanted out of our `read`.
309309
If we used it as a boolean, it knew it had to return a `Bool`.
310310
But now, it knows we want some type that is part of the `Read` class, it just doesn't know which one.
311311
Let's take a look at the type signature of `read`.
@@ -338,7 +338,7 @@ ghci> read "(3, 'a')" :: (Int, Char)
338338
Most expressions are such that the compiler can infer what their type is by itself.
339339
But sometimes, the compiler doesn't know whether to return a value of type `Int` or `Float` for an expression like `read "5"`.
340340
To see what the type is, Haskell would have to actually evaluate `read "5"`.
341-
But since Haskell is a statically typed language, it has to know all the types before the code is compiled (or in the case of GHCI, evaluated).
341+
But since Haskell is a statically typed language, it has to know all the types before the code is compiled (or in the case of GHCi, evaluated).
342342
So we have to tell Haskell: "Hey, this expression should have this type, in case you don't know!".
343343

344344
`Enum`{.label .class} members are sequentially ordered types --- they can be enumerated.

0 commit comments

Comments
 (0)