I'm teaching myself Haskell but one problem I'm running into a lot with haskell is that it's really hard to find the definitions of Haskell keywords, syntax and commands. I've gone through some Haskell tutorials and that dispelled a lot of them for me, and in general using the ":t" command in ghci is helpful to see the types of functions.
But in general, how the heck am I supposed to know what these do: (.), (>>=), (=<<), ! or \\
I know what they do now, but in the future if I run into some symbol that I've never seen before, how am I supposed to know what it does or how to use it? Googling these things obviously doesn't work!
Right now, I'm trying to figure out what the 'it' command is supposed to do in ghci. Again, I can't find this on Google, and all I know how to do is get type information via ":t it" in ghci. This is very frustrating for someone new to the language...
You can get some mileage using Hoogle:
or by searching the Prelude source code:
http://www.haskell.org/onlinereport/standard-prelude.html
https://stackoverflow.com/questions/11776269/where-can-i-find-the-source-code-for-haskell-prelude-functions
These resources will help with function names and operators, but not necessarily with learning syntax. To learn the syntax you will need other resources, or a book. Luckily though, most "syntax" at face value is in fact just a function defined in Prelude.
For GHCi commands, type :help
in GHCi. This will give you a list of all the available commands. Some of them are probably going to come in useful, like the debugging ones.
I don't know where it
is documented. In GHCi, it
is just a variable bound to the result of the last expression you evaluated. E.g.:
λ>1 + 2 * 3
7
λ>it
7
λ>:t it
it :: Integer
λ>"foo"
"foo"
λ>it
"foo"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With