Skip to content

Commit d5a09af

Browse files
Merge pull request #18 from purescript-contrib/trh/purs-tidy
Introduce purs-tidy formatter
2 parents 2262376 + df821a3 commit d5a09af

File tree

6 files changed

+52
-32
lines changed

6 files changed

+52
-32
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515

1616
- name: Set up a PureScript toolchain
1717
uses: purescript-contrib/setup-purescript@main
18+
with:
19+
purs-tidy: "latest"
1820

1921
- name: Cache PureScript dependencies
2022
uses: actions/cache@v2
@@ -38,3 +40,6 @@ jobs:
3840

3941
- name: Run tests
4042
run: spago -x test.dhall test --no-install
43+
44+
- name: Check formatting
45+
run: purs-tidy check src test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
!.gitignore
33
!.github
44
!.editorconfig
5+
!.tidyrc.json
56

67
output
78
generated-docs

.tidyrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"importSort": "source",
3+
"importWrap": "source",
4+
"indent": 2,
5+
"operatorsFile": null,
6+
"ribbon": 1,
7+
"typeArrowPlacement": "first",
8+
"unicode": "never",
9+
"width": null
10+
}

src/Data/UInt.purs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
module Data.UInt
2-
( UInt
3-
, fromInt
4-
, fromInt'
5-
, toInt
6-
, toInt'
7-
, fromNumber
8-
, fromNumber'
9-
, toNumber
10-
, floor
11-
, ceil
12-
, round
13-
, even
14-
, odd
15-
, pow
16-
, and, (.&.)
17-
, or, (.|.)
18-
, xor, (.^.)
19-
, shl
20-
, shr
21-
, zshr
22-
, complement
23-
, toString
24-
, fromString
25-
) where
2+
( UInt
3+
, fromInt
4+
, fromInt'
5+
, toInt
6+
, toInt'
7+
, fromNumber
8+
, fromNumber'
9+
, toNumber
10+
, floor
11+
, ceil
12+
, round
13+
, even
14+
, odd
15+
, pow
16+
, and
17+
, (.&.)
18+
, or
19+
, (.|.)
20+
, xor
21+
, (.^.)
22+
, shl
23+
, shr
24+
, zshr
25+
, complement
26+
, toString
27+
, fromString
28+
) where
2629

2730
import Data.Maybe (Maybe(..))
2831
import Data.Semiring (class Semiring)
@@ -39,7 +42,6 @@ import Data.Enum (class Enum)
3942
import Prelude ((<), (>), (+), (-))
4043
import Math (ceil, floor, round) as Math
4144

42-
4345
-- | 32-bit unsigned integer. Range from *0* to *4294967295*.
4446
newtype UInt = UInt Number
4547

src/Data/UInt/Gen.purs

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

7-
87
genUInt :: forall m. MonadGen m => UInt -> UInt -> m UInt
98
genUInt a b = fromNumber <$> chooseFloat (toNumber a) (toNumber b)
109

test/Main.purs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ newtype TestUInt = TestUInt UInt
1616
instance newtypeTestUInt :: Newtype TestUInt UInt
1717
instance arbitraryTestUInt :: Arbitrary TestUInt where
1818
arbitrary = TestUInt <$> genUInt bottom (fromNumber 20000.0)
19+
1920
derive newtype instance boundedTestUInt :: Bounded TestUInt
2021
derive newtype instance eqTestUInt :: Eq TestUInt
2122
derive newtype instance ordTestUInt :: Ord TestUInt
@@ -27,7 +28,7 @@ derive newtype instance euclideanRingTestUInt :: EuclideanRing TestUInt
2728

2829
main :: Effect Unit
2930
main = do
30-
let prxUInt = Proxy Proxy TestUInt
31+
let prxUInt = Proxy :: Proxy TestUInt
3132
Data.checkEq prxUInt
3233
Data.checkOrd prxUInt
3334
Data.checkSemiring prxUInt
@@ -40,14 +41,16 @@ main = do
4041

4142
checkMulIsPrecise :: Effect Unit
4243
checkMulIsPrecise = do
43-
let onlyLowBits :: TestUInt -> TestUInt
44-
onlyLowBits = over TestUInt $ and $ fromInt 0x1
44+
let
45+
onlyLowBits :: TestUInt -> TestUInt
46+
onlyLowBits = over TestUInt $ and $ fromInt 0x1
4547
quickCheck \lhs rhs ->
4648
onlyLowBits (lhs * rhs) === onlyLowBits lhs * onlyLowBits rhs
4749

4850
mulRegression1 :: Effect Unit
4951
mulRegression1 = do
50-
let lhs = fromInt (-2047875787)
51-
rhs = fromInt (-1028477387)
52-
expected = fromInt 1364097529
52+
let
53+
lhs = fromInt (-2047875787)
54+
rhs = fromInt (-1028477387)
55+
expected = fromInt 1364097529
5356
quickCheck $ lhs * rhs === expected

0 commit comments

Comments
 (0)