Skip to content

Commit

Permalink
[haskell/en] Extended section on GHCi
Browse files Browse the repository at this point in the history
- Added the :i command, as i feel that it is as useful as :t.
- Added another example for :t, hopefully showcasing it's flexibility
- For consistency, changed the name of (.) from function to operator
  (as is already the case with ($)), and added a short remark in the
  GHCi section that (most) operators are also functions.
  • Loading branch information
xou committed Oct 31, 2015
1 parent fd16cf9 commit 6086153
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions haskell.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ foo = (+10)
foo 5 -- 15

-- function composition
-- the (.) function chains functions together.
-- the operator `.` chains functions together.
-- For example, here foo is a function that takes a value. It adds 10 to it,
-- multiplies the result of that by 4, and then returns the final value.
foo = (*4) . (+10)
Expand Down Expand Up @@ -401,11 +401,26 @@ main'' = do

let foo = 5

-- You can see the type of any value with `:t`:
-- You can see the type of any value or expression with `:t`:

>:t foo
> :t foo
foo :: Integer

-- Operators, such as `+`, `:` and `$`, are functions.
-- Their type can be inspected by putting the operator in parentheses:

> :t (:)
(:) :: a -> [a] -> [a]

-- You can get additional information on any `name` using `:i`:

> :i (+)
class Num a where
(+) :: a -> a -> a
...
-- Defined in ‘GHC.Num’
infixl 6 +

-- You can also run any action of type `IO ()`

> sayHello
Expand Down

0 comments on commit 6086153

Please sign in to comment.