summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorven <vendethiel@hotmail.fr>2016-01-25 11:29:35 +0100
committerven <vendethiel@hotmail.fr>2016-01-25 11:29:35 +0100
commit8a81ef6b03a99ab9140ce89a0fb62a1d818b1118 (patch)
tree64f44bfd02b6700e229970570d266c3b4553c305
parent510f4e239e29f8a59bf9e50fe9fef4db30a44407 (diff)
parent608615360c7f49cb33c9e7eb3957e031b9b8a89c (diff)
Merge pull request #1946 from xou/haskell-operators
[haskell/en] Extended section on GHCi (discussion?)
-rw-r--r--haskell.html.markdown21
1 files changed, 18 insertions, 3 deletions
diff --git a/haskell.html.markdown b/haskell.html.markdown
index 34eee748..200e2538 100644
--- a/haskell.html.markdown
+++ b/haskell.html.markdown
@@ -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)
@@ -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