# Ticket #5565: Session.txt

File Session.txt, 3.0 KB (added by kop, 5 years ago) |
---|

Line | |
---|---|

1 | c:\Users\user\Documents\Haskell>ghci |

2 | GHCi, version 7.0.3: http://www.haskell.org/ghc/ :? for help |

3 | Loading package ghc-prim ... linking ... done. |

4 | Loading package integer-gmp ... linking ... done. |

5 | Loading package base ... linking ... done. |

6 | Loading package ffi-1.0 ... linking ... done. |

7 | Prelude> :l primes |

8 | [1 of 1] Compiling Main ( primes.hs, interpreted ) |

9 | Ok, modules loaded: Main. |

10 | *Main> :t divides |

11 | divides :: Integral a => a -> a -> Bool |

12 | *Main> :t divides 5 |

13 | divides 5 :: Integral a => a -> Bool |

14 | *Main> |

15 | *Main> :t divides 5 7 |

16 | divides 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 |

24 | 0 :: Num a => a |

25 | *Main> :t rem |

26 | rem :: 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 |

34 | div :: Integral a => a -> a -> a |

35 | *Main> :t print |

36 | print :: Show a => a -> IO () |

37 | *Main> :t ";" |

38 | ";" :: [Char] |

39 | *Main> :t print 1 |

40 | print 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 ) |

49 | Ok, modules loaded: Main. |

50 | *Main> prime0 101 |

51 | True |

52 | *Main> prime0 102 |

53 | False |

54 | *Main> prime0 1011 |

55 | False |

56 | *Main> prime0 10111 |

57 | True |

58 | *Main> prime0 101111 |

59 | True |

60 | *Main> prime0 1011111 |

61 | False |

62 | *Main> prime0 10111111 |

63 | False |

64 | *Main> prime0 101111111 |

65 | True |

66 | *Main> prime0 1011111111 |

67 | False |

68 | *Main> ld 1011111 |

69 | 3 |

70 | *Main> ld 10111111 |

71 | 29 |

72 | *Main> ld 101111111 |

73 | 101111111 |

74 | *Main> ld 1011111111 |

75 | 3 |

76 | *Main> ld 10111111111 |

77 | 101 |

78 | *Main> ld 101111111111 |

79 | 101111111111 |

80 | *Main> ld 1011111111111 |

81 | 3 |

82 | *Main> ld 10111111111111 |

83 | 5557 |

84 | *Main> ld 101111111111111 |

85 | 101 |

86 | *Main> ld 1011111111111111 |

87 | 3 |

88 | *Main> ld 10111111111111111 |

89 | 10973 |

90 | *Main> ld 101111111111111111 |

91 | |

92 | < Here I clicked Ctrl+C one or two times > |

93 | |

94 | Interrupted. |

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

104 | Ok, modules loaded: Main. |

105 | *Main> |

106 | ghc.exe: panic! (the 'impossible' happened) |

107 | (GHC version 7.0.3 for i386-unknown-mingw32): |

108 | thread blocked indefinitely in an MVar operation |

109 | |

110 | Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug |

111 | |

112 | |

113 | c:\Users\user\Documents\Haskell> |

114 | |

115 | < End of session > |

116 | |

117 | ***************************************************************************** |

118 | Contents of file primes.hs: |

119 | ***************************************************************************** |

120 | divides :: Integer -> Integer -> Bool |

121 | divides d n = rem n d == 0 |

122 | |

123 | ld :: Integer -> Integer |

124 | ld n = ldf 2 n |

125 | |

126 | ldf :: Integer -> Integer -> Integer |

127 | ldf k n | divides k n = k |

128 | | k^2 > n = n |

129 | | otherwise = ldf (k+1) n |

130 | |

131 | prime0 :: Integer -> Bool |

132 | prime0 n | n < 1 = error "not a positive number" |

133 | | n == 1 = False |

134 | | otherwise = ld n == n |