Skip to content

Commit 080eace

Browse files
authored
Format repository with purs-tidy (#296)
1 parent 3bbeca8 commit 080eace

File tree

94 files changed

+1271
-1180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1271
-1180
lines changed

.github/workflows/tests.yml

+3
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ jobs:
4848

4949
- name: Run CI tests
5050
run: make testAllCI
51+
52+
- name: Check PureScript code is formatted
53+
run: make formatCheck

.tidyrc.json

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

CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Follow these instructions for contributing new recipes. The Goal headers indicat
8080
1. Link to any other resources that a reader might find helpful. No need for detailed explanations of libraries here.
8181
1. List the `npm` dependencies your recipe uses (if any).
8282
1. Regenerate the table of recipes by running `make readme` while in the root folder
83+
1. Make sure the code is formatted consistently by running `make format`
8384
1. Submit a PR.
8485
- If this addresses a "Recipe Request" issue, the first line should read `Fixes #X` where `X` is the issue number.
8586

broken/AffGameSnakeJs/src/Main.purs

+29-31
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,15 @@ data Direction
7777

7878
derive instance eqDirection :: Eq Direction
7979

80-
type Snake
81-
= NonEmptyArray Point
80+
type Snake = NonEmptyArray Point
8281

8382
-- The type of our game state
84-
type Model
85-
= { food :: Point
86-
, snake :: Snake
87-
, direction :: Direction
88-
, genState :: GenState
89-
}
83+
type Model =
84+
{ food :: Point
85+
, snake :: Snake
86+
, direction :: Direction
87+
, genState :: GenState
88+
}
9089

9190
-- Some initial state values
9291
initialDirection :: Direction
@@ -206,8 +205,10 @@ render m = liftCanvasAction do
206205
-- `Vector2`s `ToRegion` instance:
207206
-- https://pursuit.purescript.org/packages/purescript-polymorphic-vectors/1.1.1/docs/Data.Vector.Polymorphic.Class#v:toRegionVector2
208207
fillRect
209-
$ cellSizeNum * toNumber (xmax + 2)
210-
>< cellSizeNum * toNumber (ymax + 2)
208+
$ cellSizeNum
209+
* toNumber (xmax + 2)
210+
>< cellSizeNum
211+
* toNumber (ymax + 2)
211212
-- Interior
212213
filled bgColor do
213214
fillRect $ makeRect
@@ -220,7 +221,6 @@ render m = liftCanvasAction do
220221
-- Food
221222
drawPoint foodColor m.food
222223

223-
224224
-- AFFGAME
225225
--
226226

@@ -261,32 +261,30 @@ game = mkAffGame
261261
, direction: initialDirection
262262
}
263263
pure
264-
{ env: unit :: Env
264+
{ env: unit :: Env
265265
-- We're using our `Model` type as the state of the game.
266266
, initState: initState :: Model
267267
}
268268
, updates:
269-
-- We have a `keydown` update that updates the state with the direction we
270-
-- pressed
271-
[ keydown documentEventTarget do
272-
mDir <- asksAt _keyboardEvent $ key >>> case _ of
273-
"ArrowLeft" -> Just Left
274-
"ArrowUp" -> Just Up
275-
"ArrowRight" -> Just Right
276-
"ArrowDown" -> Just Down
277-
_ -> Nothing
278-
for_ mDir \dir -> modify (update (SetDir dir))
279-
-- We also have an update that runs at our `ticksPerSecond` interval,
280-
-- but approximated to the closest (future) animation frame. We simply
281-
-- update the state, then read it again and render it to the canvas.
282-
, animationFrameMatchInterval (pure $ FPS ticksPerSecond) do
283-
modify (update Tick)
284-
get >>= render
285-
]
269+
-- We have a `keydown` update that updates the state with the direction we
270+
-- pressed
271+
[ keydown documentEventTarget do
272+
mDir <- asksAt _keyboardEvent $ key >>> case _ of
273+
"ArrowLeft" -> Just Left
274+
"ArrowUp" -> Just Up
275+
"ArrowRight" -> Just Right
276+
"ArrowDown" -> Just Down
277+
_ -> Nothing
278+
for_ mDir \dir -> modify (update (SetDir dir))
279+
-- We also have an update that runs at our `ticksPerSecond` interval,
280+
-- but approximated to the closest (future) animation frame. We simply
281+
-- update the state, then read it again and render it to the canvas.
282+
, animationFrameMatchInterval (pure $ FPS ticksPerSecond) do
283+
modify (update Tick)
284+
get >>= render
285+
]
286286
}
287287

288-
289-
290288
-- MAIN
291289
--
292290
main :: Effect Unit

0 commit comments

Comments
 (0)