Skip to content

Commit e5ed40a

Browse files
Introduce purs-tidy formatter (#28)
* Add purs-tidy formatter * Run purs-tidy
1 parent d0bda16 commit e5ed40a

File tree

8 files changed

+256
-171
lines changed

8 files changed

+256
-171
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
@@ -32,3 +34,6 @@ jobs:
3234

3335
- name: Run tests
3436
run: spago test --no-install
37+
38+
- name: Check formatting
39+
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+
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ New features:
1111
Bugfixes:
1212

1313
Other improvements:
14+
- Added `purs-tidy` formatter (#12 by @thomashoneyman)
1415

1516
## [v5.1.0](https://github.com/purescript-contrib/purescript-precise/releases/tag/v5.1.0) - 2021-05-06
1617

src/Data/Digit.purs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
module Data.Digit
22
( Digit
3-
, fromInt , toInt
4-
, fromChar , toChar
5-
, _zero, _one, _two, _three, _four, _five, _six, _seven, _eight, _nine
3+
, fromInt
4+
, toInt
5+
, fromChar
6+
, toChar
7+
, _zero
8+
, _one
9+
, _two
10+
, _three
11+
, _four
12+
, _five
13+
, _six
14+
, _seven
15+
, _eight
16+
, _nine
617
) where
718

819
import Prelude
@@ -30,10 +41,12 @@ toInt :: Digit -> Int
3041
toInt (Digit c) = c
3142

3243
fromChar :: Char -> Maybe Digit
33-
fromChar c = let code = toCharCode c
34-
in if code >= 48 && code <= 57
35-
then Just (Digit $ code - 48)
36-
else Nothing
44+
fromChar c =
45+
let
46+
code = toCharCode c
47+
in
48+
if code >= 48 && code <= 57 then Just (Digit $ code - 48)
49+
else Nothing
3750

3851
toChar :: Digit -> Char
3952
toChar (Digit c) = unsafePartial $ fromJust $ fromCharCode (c + 48)

src/Data/HugeInt.purs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ toHugeNum (HugeInt h) = h
5656

5757
-- | Requires the input to have a zero-valued fractional component.
5858
fromHugeNum :: HugeNum -> Maybe HugeInt
59-
fromHugeNum h | HN.integerPart h == h = pure $ HugeInt h
60-
| otherwise = Nothing
59+
fromHugeNum h
60+
| HN.integerPart h == h = pure $ HugeInt h
61+
| otherwise = Nothing
6162

6263
-- | Input must look like a Purescript `Int`.
6364
-- | For example, `fromString "123456789012345" => Just (HugeInt 123456789012345)`.
@@ -96,14 +97,14 @@ isNegative (HugeInt h) = HN.isNegative h
9697
numOfDigits :: HugeInt -> Int
9798
numOfDigits (HugeInt h) = HN.numOfIntegral h
9899

99-
even :: HugeInt-> Boolean
100+
even :: HugeInt -> Boolean
100101
even h = case drop (length (show h) - 1) (show h) of
101-
"0" -> true
102-
"2" -> true
103-
"4" -> true
104-
"6" -> true
105-
"8" -> true
106-
_ -> false
102+
"0" -> true
103+
"2" -> true
104+
"4" -> true
105+
"6" -> true
106+
"8" -> true
107+
_ -> false
107108

108109
odd :: HugeInt -> Boolean
109110
odd = not <<< even

src/Data/HugeInt/Gen.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Data.HugeInt.Gen where
33
import Prelude
44

55
import Control.Monad.Gen as Gen
6-
import Data.HugeInt ( HugeInt )
6+
import Data.HugeInt (HugeInt)
77
import Data.HugeInt as HugeInt
88

99
genHugeInt :: forall m. Gen.MonadGen m => m HugeInt

0 commit comments

Comments
 (0)