Question

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...

Was it helpful?

Solution

You can get some mileage using Hoogle:

or by searching the Prelude source code:

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.

OTHER TIPS

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"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top