Commit a49fbacd authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

README.md

0 → 100644
+15 −0
Changes for README.md: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
## Example files for the title:  
  
# Real World Haskell, by Bryan O'Sullivan
  
[![Real World Haskell, by Bryan O'Sullivan](http://akamaicovers.oreilly.com/images/9780596514983/cat.gif)](https://www.safaribooksonline.com/library/view/title/9780596155339//)
  
The following applies to example files from material published by O’Reilly Media, Inc. Content from other publishers may include different rules of usage. Please refer to any additional usage rights explained in the actual example files or refer to the publisher’s website.
  
O'Reilly books are here to help you get your job done. In general, you may use the code in O'Reilly books in your programs and documentation. You do not need to contact us for permission unless you're reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from our books does not require permission. Answering a question by citing our books and quoting example code does not require permission. On the other hand, selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Incorporating a significant amount of example code from our books into your product's documentation does require permission.
  
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN.
  
If you think your use of code examples falls outside fair use or the permission given here, feel free to contact us at <permissions@oreilly.com>.
  
Please note that the examples are not production code and have not been carefully testing. They are provided "as-is" and come with no warranty of any kind.
+22 −0
Changes for examples/appA/text.ghci: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
--# char

'c'
:type 'c'

--# string

"a string literal"
:type "a string literal"

--# stringlist

['a', ' ', 's', 't', 'r', 'i', 'n', 'g'] == "a string"

--# empty

"\&"
"foo\&bar"

--# empty.example

"\130\&11"
+7 −0
Changes for examples/ch00/KMinima.hs: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
import Data.List

{-- snippet minima --}
-- lines beginning with "--" are comments.

minima k xs = take k (sort xs)
{-- /snippet minima --}

examples/ch01/WC.hs

0 → 100644
+7 −0
Changes for examples/ch01/WC.hs: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
{-- snippet main --}
-- lines beginning with "--" are comments.

main = interact wordCount
    where wordCount input = show (length (lines input)) ++ "\n"
{-- /snippet main --}
  
+195 −0
Changes for examples/ch01/basics.ghci: 195 added lines, 0 removed lines.
Original line number Diff line number Diff line
--# arithmetic

2 + 2
31337 * 101
7.0 / 2.0

--# bignum

313 ^ 15

--# neg.simple

-3

--# neg.error
2 + -3

--# neg.better

2 + (-3)
3 + (-(13 * 37))

--# whitespace.ok

2*3

--# whitespace.eek

2*-3

--# whitespace.whew

2*(-3)

--# pi

pi

--# e

e

--# let

let e = exp 1

--# epipi

(e ** pi) - pi

--# boolean

True && False
False || True

--# boolean.bad

True && 1

--# comparison

1 == 1
2 < 3
4 >= 3.99

--# neq

2 /= 3

--# not

not True

--# parens

1 + (4 * 4)
1 + 4 * 4

--# precedence

:info (+)
:info (*)

--# grouping

5 * 8 / 3
5 * (8 / 3)

--# module

:module + Data.Ratio

--# denom.bad

22 % 7  *  7 % 22

--# denom.good

(22 % 7)  *  (7 % 22)

--# intpower

12 ^ 2
12.1 ^ 2

--# exponent.bad

12 ^ 2.1

--# exponent.zero

12 ^ 0
12 ^ (-1)

--# exponent.neg

12 ^^ (-2)
0 ^^ (-2)

--# exponent.float

12.2 ** 2.1

--# concat

[3,1,3] ++ [3,7]
[] ++ [False,True] ++ [True]

--# cons

1 : [2,3]
1 : []

--# string

"This is a string."

--# newline

putStrLn "Here's a newline -->\n<-- See?"

--# list

[1, 2, 3]

--# list.shortlong

[]
["foo", "bar", "baz", "quux", "fnord", "xyzzy"]

--# list.bad

[True, False, "testing"]

--# range

[1..10]

--# range.step

[1.0,1.25..2.0]
[1,4..15]
[10,9..1]

--# char

'a'

--# range.char

['a','e'..'z']

--# work

let a = ['l', 'o', 't', 's', ' ', 'o', 'f', ' ', 'w', 'o', 'r', 'k']
a
a == "lots of work"

--# emptystring
"" == []

--# newstring
'a':"bc"
"foo" ++ "bar"

--# range.double

[1.0..1.8]

--# prefix
2 + 2
(+) 2 2

--# caret
:info (^)
Loading