Skip to content

Commit 1d5f09b

Browse files
committed
Prep for v1.0.0
1 parent 9aa3816 commit 1d5f09b

File tree

8 files changed

+42
-22
lines changed

8 files changed

+42
-22
lines changed

.github/workflows/ci.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,11 @@ jobs:
3030
- name: Build source
3131
run: spago build --no-install --purs-args '--censor-lib --strict'
3232

33+
- name: Install test dependencies
34+
run: spago -x test.dhall install
35+
36+
- name: Build tests
37+
run: spago -x test.dhall build --no-install --purs-args '--censor-lib --strict'
38+
3339
- name: Run tests
34-
run: spago test --no-install
40+
run: spago -x test.dhall test --no-install

CHANGELOG.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Notable changes to this project are documented in this file. The format is based
44

55
## [Unreleased]
66

7-
Breaking changes (😱!!!):
7+
## v1.0.0 2021-06-23
88

9-
New features:
9+
Thank you Athan Clark for donating this package to __purescript-contrib__.
1010

11-
Bugfixes:
11+
Remove the `Generic` instance of `Float32`, it’s no longer needed. We don't
12+
expect this change to break any dependent code.
1213

13-
Other improvements:
14+
Move the testing dependencies to `test.dhall`.

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
# Float32
1+
# float32
22

33
[![CI](https://github.com/purescript-contrib/purescript-float32/workflows/CI/badge.svg?branch=main)](https://github.com/purescript-contrib/purescript-float32/actions?query=workflow%3ACI+branch%3Amain)
44
[![Release](https://img.shields.io/github/release/purescript-contrib/purescript-float32.svg)](https://github.com/purescript-contrib/purescript-float32/releases)
55
[![Pursuit](https://pursuit.purescript.org/packages/purescript-float32/badge)](https://pursuit.purescript.org/packages/purescript-float32)
66
[![Maintainer: jamesdbrock](https://img.shields.io/badge/maintainer-jamesdbrock-teal.svg)](https://github.com/jamesdbrock)
77

8-
The library summary hasn't been written yet (contributions are welcome!). The library summary describes the library's purpose in one to three sentences.
8+
Provides the
9+
[32-bit single-precision floating-point](https://en.wikipedia.org/wiki/Single-precision_floating-point_format)
10+
data type `Float32` and operations.
11+
12+
`Float32` is a `newtype` wrapper around `Number`, where
13+
entering into the type can only be done with
14+
[`Math.fround()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround).
915

1016
## Installation
1117

@@ -41,3 +47,11 @@ You can contribute to `float32` in several ways:
4147
2. If you would like to contribute code, tests, or documentation, please [read the contributor guide](./CONTRIBUTING.md). It's a short, helpful introduction to contributing to this library, including development instructions.
4248

4349
3. If you have written a library, tutorial, guide, or other resource based on this package, please share it on the [PureScript Discourse](https://discourse.purescript.org)! Writing libraries and learning resources are a great way to help this library succeed.
50+
51+
## Development
52+
53+
Run the tests with
54+
55+
```sh
56+
spago -x test.dhall test
57+
```

bower.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
],
66
"repository": {
77
"type": "git",
8-
"url": "https://github.com/jamesdbrock/purescript-float32.git"
8+
"url": "https://github.com/purescript-contrib/purescript-float32.git"
99
},
1010
"ignore": [
1111
"**/.*",
@@ -14,7 +14,6 @@
1414
"output"
1515
],
1616
"dependencies": {
17-
"purescript-effect": "^v3.0.0",
1817
"purescript-gen": "^v3.0.0",
1918
"purescript-maybe": "^v5.0.0",
2019
"purescript-prelude": "^v5.0.0",

spago.dhall

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{ name = "float32"
22
, license = "BSD-3-Clause"
33
, dependencies =
4-
[ "effect"
5-
, "gen"
4+
[ "gen"
65
, "maybe"
76
, "prelude"
87
, "psci-support"
98
]
109
, packages = ./packages.dhall
1110
, sources = [ "src/**/*.purs" ]
12-
, repository = "https://github.com/jamesdbrock/purescript-float32.git"
11+
, repository = "https://github.com/purescript-contrib/purescript-float32.git"
1312
}

src/Data/Float32.purs

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import Prelude
66
( class Eq, class Ord, class Show, class Semiring, class Ring, class Bounded, class EuclideanRing
77
, class CommutativeRing, class DivisionRing
88
, top, bottom, (==), (||))
9-
import Data.Generic.Rep (class Generic)
109
import Data.Maybe (Maybe (..))
1110

11+
-- | [32-bit single-precision floating-point](https://en.wikipedia.org/wiki/Single-precision_floating-point_format)
12+
-- | number.
1213
newtype Float32 = Float32 Number
1314

14-
derive instance genericeFloat32 :: Generic Float32 _
1515
derive newtype instance eqFloat32 :: Eq Float32
1616
derive newtype instance ordFloat32 :: Ord Float32
1717
derive newtype instance semiringFloat32 :: Semiring Float32
@@ -29,13 +29,15 @@ foreign import float32Top :: Float32
2929
foreign import float32Bottom :: Float32
3030

3131

32-
-- | Uses `Math.fround()` to convert to a 32bit float
32+
-- | Uses `Math.fround()` to convert to a `Float32`.
33+
-- | Returns `Nothing` when outside the range.
3334
fromNumber :: Number -> Maybe Float32
3435
fromNumber x =
3536
let r = fromNumberImpl x
3637
in if r == top || r == bottom then Nothing else Just (Float32 r)
3738

38-
-- | Casts to `0` when outside the range.
39+
-- | Uses `Math.fround()` to convert to a `Float32`.
40+
-- | Returns *0.0* when outside the range.
3941
fromNumber' :: Number -> Float32
4042
fromNumber' x = case fromNumber x of
4143
Nothing -> Float32 0.0

test.dhall

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ let conf = ./spago.dhall
22

33
in conf // {
44
, dependencies = conf.dependencies #
5-
[ "quickcheck"
5+
[ "effect"
6+
, "quickcheck"
67
, "quickcheck-laws"
78
]
89
, sources = conf.sources # [ "test/**/*.purs" ]

test/Main.purs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
module Test.Main where
22

33
import Prelude
4+
45
import Data.Float32 (Float32)
56
import Data.Float32.Gen (chooseFloat32)
6-
77
import Effect (Effect)
8-
import Type.Proxy (Proxy (..))
98
import Test.QuickCheck (class Arbitrary)
10-
import Test.QuickCheck.Laws.Data
11-
( checkBounded, checkEq, checkOrd, checkSemiring, checkRing, checkCommutativeRing
12-
, checkDivisionRing, checkEuclideanRing)
9+
import Test.QuickCheck.Laws.Data (checkBounded, checkCommutativeRing, checkEq, checkOrd, checkRing, checkSemiring)
10+
import Type.Proxy (Proxy(..))
1311

1412
newtype Float32' = Float32' Float32
1513
derive newtype instance eqFloat32' :: Eq Float32'

0 commit comments

Comments
 (0)