Ticket #5565: Session.txt

File Session.txt, 3.0 KB (added by kop, 4 years ago)

Full session and contents of loaded file

Line 
1c:\Users\user\Documents\Haskell>ghci
2GHCi, version 7.0.3: http://www.haskell.org/ghc/  :? for help
3Loading package ghc-prim ... linking ... done.
4Loading package integer-gmp ... linking ... done.
5Loading package base ... linking ... done.
6Loading package ffi-1.0 ... linking ... done.
7Prelude> :l primes
8[1 of 1] Compiling Main             ( primes.hs, interpreted )
9Ok, modules loaded: Main.
10*Main> :t divides
11divides :: Integral a => a -> a -> Bool
12*Main> :t divides 5
13divides 5 :: Integral a => a -> Bool
14*Main>
15*Main> :t divides 5 7
16divides 5 7 :: Bool
17*Main> :t divides 5 7 1
18
19<interactive>:1:1:
20    The function `divides' is applied to three arguments,
21    but its type `a0 -> a0 -> Bool' has only two
22    In the expression: divides 5 7 1
23*Main> :t 0
240 :: Num a => a
25*Main> :t rem
26rem :: Integral a => a -> a -> a
27*Main> :t *
28
29<interactive>:1:1: parse error on input `*'
30*Main> :t `*`
31
32<interactive>:1:1: parse error on input ``'
33*Main> :t div
34div :: Integral a => a -> a -> a
35*Main> :t print
36print :: Show a => a -> IO ()
37*Main> :t ";"
38";" :: [Char]
39*Main> :t print 1
40print 1 :: IO ()
41*Main> :t ==
42
43<interactive>:1:1: parse error on input `=='
44*Main> :t eq
45
46<interactive>:1:1: Not in scope: `eq'
47*Main> :r
48[1 of 1] Compiling Main             ( primes.hs, interpreted )
49Ok, modules loaded: Main.
50*Main> prime0 101
51True
52*Main> prime0 102
53False
54*Main> prime0 1011
55False
56*Main> prime0 10111
57True
58*Main> prime0 101111
59True
60*Main> prime0 1011111
61False
62*Main> prime0 10111111
63False
64*Main> prime0 101111111
65True
66*Main> prime0 1011111111
67False
68*Main> ld 1011111
693
70*Main> ld 10111111
7129
72*Main> ld 101111111
73101111111
74*Main> ld 1011111111
753
76*Main> ld 10111111111
77101
78*Main> ld 101111111111
79101111111111
80*Main> ld 1011111111111
813
82*Main> ld 10111111111111
835557
84*Main> ld 101111111111111
85101
86*Main> ld 1011111111111111
873
88*Main> ld 10111111111111111
8910973
90*Main> ld 101111111111111111
91
92< Here I clicked Ctrl+C one or two times >
93
94Interrupted.
95*Main> ld 101111111111111111
96
97< And here clicked Ctrl+C possibly too >
98
99*Main>
100*Main>
101*Main>
102*Main> :r
103[1 of 1] Compiling Main             ( primes.hs, interpreted )
104Ok, modules loaded: Main.
105*Main>
106ghc.exe: panic! (the 'impossible' happened)
107  (GHC version 7.0.3 for i386-unknown-mingw32):
108        thread blocked indefinitely in an MVar operation
109
110Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
111
112
113c:\Users\user\Documents\Haskell>
114
115< End of session >
116
117*****************************************************************************
118Contents of file primes.hs:
119*****************************************************************************
120divides :: Integer -> Integer -> Bool
121divides d n = rem n d == 0
122
123ld :: Integer -> Integer
124ld n = ldf 2 n
125
126ldf :: Integer -> Integer -> Integer
127ldf k n | divides k n = k
128        | k^2 > n     = n
129        | otherwise   = ldf (k+1) n
130
131prime0 :: Integer -> Bool
132prime0 n | n < 1     = error "not a positive number"
133         | n == 1    = False
134         | otherwise = ld n == n