Skip to content

Format repository with purs-tidy #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ jobs:

- name: Run CI tests
run: make testAllCI

- name: Check PureScript code is formatted
run: make formatCheck
10 changes: 10 additions & 0 deletions .tidyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"importSort": "ide",
"importWrap": "source",
"indent": 2,
"operatorsFile": null,
"ribbon": 1,
"typeArrowPlacement": "first",
"unicode": "never",
"width": null
}
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Follow these instructions for contributing new recipes. The Goal headers indicat
1. Link to any other resources that a reader might find helpful. No need for detailed explanations of libraries here.
1. List the `npm` dependencies your recipe uses (if any).
1. Regenerate the table of recipes by running `make readme` while in the root folder
1. Make sure the code is formatted consistently by running `make format`
1. Submit a PR.
- If this addresses a "Recipe Request" issue, the first line should read `Fixes #X` where `X` is the issue number.

Expand Down
60 changes: 29 additions & 31 deletions broken/AffGameSnakeJs/src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,15 @@ data Direction

derive instance eqDirection :: Eq Direction

type Snake
= NonEmptyArray Point
type Snake = NonEmptyArray Point

-- The type of our game state
type Model
= { food :: Point
, snake :: Snake
, direction :: Direction
, genState :: GenState
}
type Model =
{ food :: Point
, snake :: Snake
, direction :: Direction
, genState :: GenState
}

-- Some initial state values
initialDirection :: Direction
Expand Down Expand Up @@ -206,8 +205,10 @@ render m = liftCanvasAction do
-- `Vector2`s `ToRegion` instance:
-- https://pursuit.purescript.org/packages/purescript-polymorphic-vectors/1.1.1/docs/Data.Vector.Polymorphic.Class#v:toRegionVector2
fillRect
$ cellSizeNum * toNumber (xmax + 2)
>< cellSizeNum * toNumber (ymax + 2)
$ cellSizeNum
* toNumber (xmax + 2)
>< cellSizeNum
* toNumber (ymax + 2)
-- Interior
filled bgColor do
fillRect $ makeRect
Expand All @@ -220,7 +221,6 @@ render m = liftCanvasAction do
-- Food
drawPoint foodColor m.food


-- AFFGAME
--

Expand Down Expand Up @@ -261,32 +261,30 @@ game = mkAffGame
, direction: initialDirection
}
pure
{ env: unit :: Env
{ env: unit :: Env
-- We're using our `Model` type as the state of the game.
, initState: initState :: Model
}
, updates:
-- We have a `keydown` update that updates the state with the direction we
-- pressed
[ keydown documentEventTarget do
mDir <- asksAt _keyboardEvent $ key >>> case _ of
"ArrowLeft" -> Just Left
"ArrowUp" -> Just Up
"ArrowRight" -> Just Right
"ArrowDown" -> Just Down
_ -> Nothing
for_ mDir \dir -> modify (update (SetDir dir))
-- We also have an update that runs at our `ticksPerSecond` interval,
-- but approximated to the closest (future) animation frame. We simply
-- update the state, then read it again and render it to the canvas.
, animationFrameMatchInterval (pure $ FPS ticksPerSecond) do
modify (update Tick)
get >>= render
]
-- We have a `keydown` update that updates the state with the direction we
-- pressed
[ keydown documentEventTarget do
mDir <- asksAt _keyboardEvent $ key >>> case _ of
"ArrowLeft" -> Just Left
"ArrowUp" -> Just Up
"ArrowRight" -> Just Right
"ArrowDown" -> Just Down
_ -> Nothing
for_ mDir \dir -> modify (update (SetDir dir))
-- We also have an update that runs at our `ticksPerSecond` interval,
-- but approximated to the closest (future) animation frame. We simply
-- update the state, then read it again and render it to the canvas.
, animationFrameMatchInterval (pure $ FPS ticksPerSecond) do
modify (update Tick)
get >>= render
]
}



-- MAIN
--
main :: Effect Unit
Expand Down
Loading