@@ -33,6 +33,7 @@ runSmallInt (SmallInt n) = n
3333
3434--  | Arbitrary instance for BigInt
3535newtype  TestBigInt  = TestBigInt  BigInt 
36+ 
3637derive newtype instance  eqTestBigInt  :: Eq  TestBigInt 
3738derive newtype instance  ordTestBigInt  :: Ord  TestBigInt 
3839derive newtype instance  semiringTestBigInt  :: Semiring  TestBigInt 
@@ -43,21 +44,24 @@ derive newtype instance euclideanRingTestBigInt :: EuclideanRing TestBigInt
4344instance  arbitraryBigInt  :: Arbitrary  TestBigInt  where 
4445  arbitrary = do 
4546    n <-  (fromMaybe zero <<< fromString) <$> digitString
46-     op <-  elements (cons' identity [negate])
47+     op <-  elements (cons' identity [  negate  ])
4748    pure (TestBigInt  (op n))
48-     where  digits ::  Gen  Int 
49-           digits = chooseInt 0   9 
50-           digitString  ::  Gen  String 
51-           digitString = (fold <<< map show) <$> (resize 50   $ arrayOf digits)
49+     where 
50+     digits  ::  Gen  Int 
51+     digits = chooseInt 0   9 
52+ 
53+     digitString  ::  Gen  String 
54+     digitString = (fold <<< map show) <$> (resize 50   $ arrayOf digits)
5255
5356--  | Convert SmallInt to BigInt
5457fromSmallInt  ::  SmallInt  ->  BigInt 
5558fromSmallInt = fromInt <<< runSmallInt
5659
5760--  | Test if a binary relation holds before and after converting to BigInt.
58- testBinary  ::  (BigInt  ->  BigInt  ->  BigInt )
59-            ->  (Int  ->  Int  ->  Int )
60-            ->  Effect  Unit 
61+ testBinary
62+   ::  (BigInt  ->  BigInt  ->  BigInt )
63+   ->  (Int  ->  Int  ->  Int )
64+   ->  Effect  Unit 
6165testBinary f g = quickCheck (\x y ->  (fromInt x) `f` (fromInt y) == fromInt (x `g`  y))
6266
6367main  ::  Effect  Unit 
@@ -89,16 +93,18 @@ main = do
8993  assert $ toString (fromInt 12345  ) == " 12345" 
9094
9195  log " Converting bigints to arrays with a different base" 
92-   assert $ NEA .toArray (digitsInBase 2   four).value == [1  , 0  , 0  ]
93-   assert $ (NEA .toArray <<< _.value <<< digitsInBase 16   <$>
94-            fromString " 255"  ) == Just  [15  , 15  ]
96+   assert $ NEA .toArray (digitsInBase 2   four).value == [ 1  , 0  , 0   ]
97+   assert $
98+     ( NEA .toArray <<< _.value <<< digitsInBase 16   <$>
99+         fromString " 255" 
100+     ) == Just  [ 15  , 15   ]
95101  assert $ NEA .toArray (digitsInBase 10   $ fromInt 12345  ).value
96-             == [1  , 2  , 3  , 4  , 5  ]
102+     == [  1  , 2  , 3  , 4  , 5   ]
97103
98104  assert $ toBase' 2   four == unsafePartial unsafeFromString " 100" 
99105  assert $ (toBase' 16   <$> fromString " 255"  ) == NES .fromString " ff" 
100106  assert $ toNonEmptyString (fromInt 12345  )
101-             == unsafePartial unsafeFromString " 12345" 
107+     == unsafePartial unsafeFromString " 12345" 
102108
103109  log " Converting from Number to BigInt" 
104110  assert $ fromNumber 0.0   == Just  zero
@@ -140,7 +146,7 @@ main = do
140146  assert $ zero `pow`  zero == one
141147
142148  log " Prime numbers" 
143-   assert $ filter (prime <<< fromInt) (range 2   20  ) == [2  , 3  , 5  , 7  , 11  , 13  , 17  , 19  ]
149+   assert $ filter (prime <<< fromInt) (range 2   20  ) == [  2  , 3  , 5  , 7  , 11  , 13  , 17  , 19   ]
144150
145151  log " Absolute value" 
146152  quickCheck $ \(TestBigInt  x) ->  abs x == if  x > zero then  x else  (-x)
@@ -178,12 +184,15 @@ main = do
178184  assert $ (fromString " -2147483649"   >>= toInt) == Nothing 
179185  assert $ (fromString " 921231231322337203685124775809"   >>= toInt) == Nothing 
180186  assert $ (fromString " -922337203612312312312854775809"   >>= toInt) == Nothing 
181-   quickCheck (\a b c -> 
182-                let  x = add (fromInt a) (add (fromInt b) (fromInt c))
183-                in  case  toInt x of 
184-                  Nothing  ->  x < fromInt (-2147483648  ) || x > fromInt 2147483647 
185-                  Just  i ->  fromInt i == x
186-              )
187+   quickCheck
188+     ( \a b c -> 
189+         let 
190+           x = add (fromInt a) (add (fromInt b) (fromInt c))
191+         in 
192+           case  toInt x of 
193+             Nothing  ->  x < fromInt (-2147483648  ) || x > fromInt 2147483647 
194+             Just  i ->  fromInt i == x
195+     )
187196
188197  log " Type Level Int creation" 
189198  assert $ toString (fromTLInt (Proxy  ::  Proxy  921231231322337203685124775809)) == " 921231231322337203685124775809" 
0 commit comments