Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
zyla committed Feb 11, 2024
1 parent 8a0139b commit 5e0f93c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
19 changes: 10 additions & 9 deletions bench/Bench/Builder.purs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ foreign import replicateM_Widget_ :: Int -> Widget Unit -> Widget Unit
staticWidgetNewApi :: Int -> Widget Unit
staticWidgetNewApi n =
replicateM_Widget_ n $
E.el "div" [E.attrs ("class" := "foo")] do
E.el "div" [E.attrs ("class" := "bar")] do
E.el "div" [ E.attrs ("class" := "foo") ] do
E.el "div" [ E.attrs ("class" := "bar") ] do
E.text "foo"
E.el "div" [E.attrs ("class" := "baz")] do
E.el "div" [ E.attrs ("class" := "baz") ] do
E.text "foo"
E.el "div" [E.attrs ("class" := "thud")] do
E.el "div" [ E.attrs ("class" := "thud") ] do
E.text "foo"

staticWidgetNewApiD :: Int -> Widget Unit
staticWidgetNewApiD n =
replicateM_Widget_ n $
E.el "div" [E.attrsD (pure ("class" := "foo"))] do
E.el "div" [E.attrsD (pure ("class" := "bar"))] do
E.el "div" [ E.attrsD (pure ("class" := "foo")) ] do
E.el "div" [ E.attrsD (pure ("class" := "bar")) ] do
E.text "foo"
E.el "div" [E.attrsD (pure ("class" := "baz"))] do
E.el "div" [ E.attrsD (pure ("class" := "baz")) ] do
E.text "foo"
E.el "div" [E.attrsD (pure ("class" := "thud"))] do
E.el "div" [ E.attrsD (pure ("class" := "thud")) ] do
E.text "foo"

-- See comments in the FFI module.
Expand All @@ -50,7 +50,8 @@ builderTests =
, Tuple "Widget + attrD " (pure $ delay \_ -> runWidget $ staticWidgetNewApiD 10)
]

where delay x = pure unit >>= x
where
delay x = pure unit >>= x

-- mechanics

Expand Down
28 changes: 15 additions & 13 deletions bench/Bench/Primitives.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Bench.Primitives ( dynamicTests) where
module Bench.Primitives (dynamicTests) where

import Prelude

Expand All @@ -18,16 +18,18 @@ dynamicTests =
, Tuple "20 subscribers" $ nsubscribers 20
, Tuple "30 subscribers" $ nsubscribers 30
, Tuple "40 subscribers" $ nsubscribers 40
] <>
[ Tuple "dyn" $ testDynFn1 pure
, Tuple "dyn fmap" $ testDynFn1 \d -> pure (add 1 <$> d)
, Tuple "dyn ap pure" $ testDynFn1 \d -> pure (pure (const 1) <*> d)
, Tuple "dyn ap self" $ testDynFn1 \d -> pure (add <$> d <*> d)
, Tuple "dyn bind self" $ testDynFn1 \d -> pure (d >>= \_ -> d)
, Tuple "dyn bind inner" $ testDynFn1 \d -> pure (pure 10 >>= \_ -> d)
, Tuple "dyn bind outer" $ testDynFn1 \d -> pure (d >>= \_ -> pure 10)
] <>
nestedApplyTests
]
<>
[ Tuple "dyn" $ testDynFn1 pure
, Tuple "dyn fmap" $ testDynFn1 \d -> pure (add 1 <$> d)
, Tuple "dyn ap pure" $ testDynFn1 \d -> pure (pure (const 1) <*> d)
, Tuple "dyn ap self" $ testDynFn1 \d -> pure (add <$> d <*> d)
, Tuple "dyn bind self" $ testDynFn1 \d -> pure (d >>= \_ -> d)
, Tuple "dyn bind inner" $ testDynFn1 \d -> pure (pure 10 >>= \_ -> d)
, Tuple "dyn bind outer" $ testDynFn1 \d -> pure (d >>= \_ -> pure 10)
]
<>
nestedApplyTests

nestedApplyTests :: Tests
nestedApplyTests =
Expand All @@ -48,14 +50,14 @@ nestedApplyTests =
dynamics <- sequence $ replicate n do
event <- newEvent
holdDyn 0 event.event
pure $ map sum $ sequence ([d] <> dynamics)
pure $ map sum $ sequence ([ d ] <> dynamics)

test_n_ap_last n =
testDynFn1 \d -> do
dynamics <- sequence $ replicate n do
event <- newEvent
holdDyn 0 event.event
pure $ map sum $ sequence (dynamics <> [d])
pure $ map sum $ sequence (dynamics <> [ d ])

nsubscribers :: Int -> Effect (Effect Unit)
nsubscribers n =
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build-bench": "spago bundle-app --main BenchMain --to output/BenchMain.js",
"open-bench": "xdg-open ./bench/benchmark.html",
"run-bench": "node bench/run.js",
"format": "purs-tidy format-in-place 'src/**/*.purs' 'test/**/*.purs' && prettier -w src test"
"format": "purs-tidy format-in-place 'src/**/*.purs' 'test/**/*.purs' 'bench/**/*.purs' && prettier -w src test"
},
"author": "Maciej Bielecki <zyla@prati.pl>",
"license": "MIT",
Expand Down

0 comments on commit 5e0f93c

Please sign in to comment.