65 | | -- Minimal complete definition: |
66 | | -- (*) and (one or fromInteger) |
67 | | one = fromInteger 1 |
68 | | fromInteger n |
69 | | | n < 0 = negate (fi (negate n)) |
70 | | | otherwise = fi n |
71 | | where fi 0 = zero |
72 | | fi 1 = one |
73 | | fi n |
74 | | | even n = fin + fin |
75 | | | otherwise = fin + fin + one |
76 | | where fin = fi (n `div` 2) |
| 65 | -- Minimal complete definition: |
| 66 | -- (*) and (one or fromInteger) |
| 67 | one = fromInteger 1 |
| 68 | fromInteger n |
| 69 | | n < 0 = negate (fi (negate n)) |
| 70 | | otherwise = fi n |
| 71 | where fi 0 = zero |
| 72 | fi 1 = one |
| 73 | fi n |
| 74 | | even n = fin + fin |
| 75 | | otherwise = fin + fin + one |
| 76 | where fin = fi (n `div` 2) |
152 | | -- Minimal complete definition: |
153 | | -- (divMod or (div and mod)) and stdUnit |
154 | | n `divMod` d = (n `div` d, n `mod` d) |
155 | | n `div` d = q where (q,r) = divMod n d |
156 | | n `mod` d = r where (q,r) = divMod n d |
157 | | |
158 | | stdAssociate x = x `div` stdUnit x |
| 152 | -- Minimal complete definition: |
| 153 | -- (divMod or (div and mod)) and stdUnit |
| 154 | n `divMod` d = (n `div` d, n `mod` d) |
| 155 | n `div` d = q where (q,r) = divMod n d |
| 156 | n `mod` d = r where (q,r) = divMod n d |
| 157 | |
| 158 | stdAssociate x = x `div` stdUnit x |
167 | | -- Minimal complete definition: |
168 | | -- toInteger |
169 | | n `quot` d = q where (q,r) = quotRem n d |
170 | | n `rem` d = r where (q,r) = quotRem n d |
171 | | quotRem n d = if signum r == - signum d then (q+one, r-d) else qr |
172 | | where qr@(q,r) = divMod n d |
| 167 | -- Minimal complete definition: |
| 168 | -- toInteger |
| 169 | n `quot` d = q where (q,r) = quotRem n d |
| 170 | n `rem` d = r where (q,r) = quotRem n d |
| 171 | quotRem n d = if signum r == - signum d then (q+one, r-d) else qr |
| 172 | where qr@(q,r) = divMod n d |