Skip to content

Commit 75cd7e7

Browse files
Run purs-tidy
1 parent d1e71ae commit 75cd7e7

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

src/Data/Float32.purs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
module Data.Float32
2-
( Float32, fromNumber, fromNumber', toNumber
2+
( Float32
3+
, fromNumber
4+
, fromNumber'
5+
, toNumber
36
) where
47

58
import Prelude
6-
( class Eq, class Ord, class Show, class Semiring, class Ring, class Bounded, class EuclideanRing
7-
, class CommutativeRing, class DivisionRing
8-
, top, bottom, (==), (||))
9-
import Data.Maybe (Maybe (..))
9+
( class Eq
10+
, class Ord
11+
, class Show
12+
, class Semiring
13+
, class Ring
14+
, class Bounded
15+
, class EuclideanRing
16+
, class CommutativeRing
17+
, class DivisionRing
18+
, top
19+
, bottom
20+
, (==)
21+
, (||)
22+
)
23+
import Data.Maybe (Maybe(..))
1024

1125
-- | [32-bit single-precision floating-point](https://en.wikipedia.org/wiki/Single-precision_floating-point_format)
1226
-- | number.
@@ -24,17 +38,17 @@ instance boundedFloat32 :: Bounded Float32 where
2438
top = float32Top
2539
bottom = float32Bottom
2640

27-
2841
foreign import float32Top :: Float32
2942
foreign import float32Bottom :: Float32
3043

31-
3244
-- | Uses `Math.fround()` to convert to a `Float32`.
3345
-- | Returns `Nothing` when outside the range.
3446
fromNumber :: Number -> Maybe Float32
3547
fromNumber x =
36-
let r = fromNumberImpl x
37-
in if r == top || r == bottom then Nothing else Just (Float32 r)
48+
let
49+
r = fromNumberImpl x
50+
in
51+
if r == top || r == bottom then Nothing else Just (Float32 r)
3852

3953
-- | Uses `Math.fround()` to convert to a `Float32`.
4054
-- | Returns *0.0* when outside the range.
@@ -43,7 +57,6 @@ fromNumber' x = case fromNumber x of
4357
Nothing -> Float32 0.0
4458
Just y -> y
4559

46-
4760
foreign import fromNumberImpl :: Number -> Number
4861

4962
toNumber :: Float32 -> Number

src/Data/Float32/Gen.purs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ import Prelude ((<$>))
44
import Data.Float32 (Float32, fromNumber', toNumber)
55
import Control.Monad.Gen.Class (class MonadGen, chooseFloat)
66

7-
87
chooseFloat32 :: forall m. MonadGen m => Float32 -> Float32 -> m Float32
98
chooseFloat32 a b = fromNumber' <$> chooseFloat (toNumber a) (toNumber b)

test/Main.purs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Test.QuickCheck.Laws.Data (checkBounded, checkCommutativeRing, checkEq, c
1010
import Type.Proxy (Proxy(..))
1111

1212
newtype Float32' = Float32' Float32
13+
1314
derive newtype instance eqFloat32' :: Eq Float32'
1415
derive newtype instance ordFloat32' :: Ord Float32'
1516
derive newtype instance boundedFloat32' :: Bounded Float32'
@@ -21,26 +22,17 @@ derive newtype instance euclideanRingFloat32' :: EuclideanRing Float32'
2122
instance arbitraryFloat32' :: Arbitrary Float32' where
2223
arbitrary = Float32' <$> chooseFloat32 bottom top
2324

24-
2525
main :: Effect Unit
2626
main = do
27-
let p :: Proxy Float32'
28-
p = Proxy
27+
let
28+
p :: Proxy Float32'
29+
p = Proxy
2930
checkBounded p
3031
checkEq p
3132
checkOrd p
3233
checkSemiring p
3334
checkRing p
3435
checkCommutativeRing p
35-
-- checkDivisionRing p -- isn't a division ring because 32bit float isn't perfectly precise
36-
-- checkEuclideanRing p -- likewise for euclidean ring
37-
38-
39-
40-
41-
42-
43-
44-
45-
36+
-- checkDivisionRing p -- isn't a division ring because 32bit float isn't perfectly precise
37+
-- checkEuclideanRing p -- likewise for euclidean ring
4638

0 commit comments

Comments
 (0)