Skip to content
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

Reformat everything with ormolu, add workflow to automatically fix formatting in the future #1127

Merged
merged 12 commits into from
Jan 27, 2025
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
18 changes: 17 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,20 @@ jobs:

- name: test
run: cabal v2-test ${{ matrix.versions.args }} --enable-tests --enable-benchmarks all

ormolu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/run-ormolu@v17
with:
mode: inplace
pattern: |
src/**/*.hs
tidal-link/src/**/*.hs
tidal-parse/src/**/*.hs
tidal-listener/src/**/*.hs
- name: apply ormolu formatting
uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ always() }}
with:
commit_message: automated ormolu reformatting
1 change: 1 addition & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import Distribution.Simple

main = defaultMain
10 changes: 5 additions & 5 deletions bench/Memory/Main.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Main where
module Main where

import Weigh
import Tidal.UIB
import Weigh

main :: IO ()
main =
mainWith $ do
main :: IO ()
main =
mainWith $ do
euclidB
fixB
40 changes: 20 additions & 20 deletions bench/Memory/Tidal/Inputs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

module Tidal.Inputs where

import Sound.Tidal.Pattern
import Sound.Tidal.Control
import Sound.Tidal.Core
import Sound.Tidal.ParseBP()
import Sound.Tidal.Params
import Sound.Tidal.Control
import Sound.Tidal.ParseBP ()
import Sound.Tidal.Pattern
import Sound.Tidal.UI
import Weigh

Expand All @@ -15,19 +15,19 @@ columns = setColumns [Case, Allocated, Max, Live, GCs]

{- Pattern inputs -}
xs3 :: [Time]
xs3 = [1..10000]
xs3 = [1 .. 10000]

xs4 :: [Time]
xs4 = [1..100000]
xs4 = [1 .. 100000]

xs5 :: [Time]
xs5 = [1..1000000]
xs5 = [1 .. 1000000]

xs6 :: [Time]
xs6 = [1..10000000]
xs6 = [1 .. 10000000]

xsA :: [Time]
xsA = [500000..1500000]
xsA = [500000 .. 1500000]

catPattSmall :: [Pattern Time]
catPattSmall = pure <$> xs3
Expand Down Expand Up @@ -72,18 +72,18 @@ fixArg1 = pF "cc64" 1

fixArg2 :: ControlPattern
fixArg2 =
fix ( # crush 4 ) (pF "cc65" 1)
$ fix ( stut' 4 (0.125/4) ( + up "1" )) (pF "cc66" 1)
$ fix ( |*| speed "-1" ) (pF "cc67" 1)
$ fix ( (# delaytime 0.125).(# delay 0.5)) (pF "cc68" 1)
$ fix ( # coarse 12) (pF "cc69" 1)
$ s "[808bd:1(3,8), dr(7,8)]"
# pF "cc64" (cF 0 "64")
# pF "cc65" (cF 0 "65")
# pF "cc66" (cF 0 "66")
# pF "cc67" (cF 0 "67")
# pF "cc68" (cF 0 "68")
pF "cc69" (cF 0 "69")
fix (# crush 4) (pF "cc65" 1) $
fix (stut' 4 (0.125 / 4) (+ up "1")) (pF "cc66" 1) $
fix (|*| speed "-1") (pF "cc67" 1) $
fix ((# delaytime 0.125) . (# delay 0.5)) (pF "cc68" 1) $
fix (# coarse 12) (pF "cc69" 1) $
s "[808bd:1(3,8), dr(7,8)]"
# pF "cc64" (cF 0 "64")
# pF "cc65" (cF 0 "65")
# pF "cc66" (cF 0 "66")
# pF "cc67" (cF 0 "67")
# pF "cc68" (cF 0 "68")
# pF "cc69" (cF 0 "69")

{- Euclid inputs -}
ecA1 :: [Pattern Int]
Expand Down
18 changes: 9 additions & 9 deletions bench/Memory/Tidal/UIB.hs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module Tidal.UIB where
module Tidal.UIB where

import Weigh
import Tidal.Inputs
import Sound.Tidal.Context
import Tidal.Inputs
import Weigh

fixB :: Weigh ()
fixB =
fixB :: Weigh ()
fixB =
wgroup "fix weigh" $ do
columns
func "fix 1" (fix (fast 2) fixArg1) fixArg2

euclidB :: Weigh ()
euclidB =
wgroup "euclid" $ do
columns
euclidB :: Weigh ()
euclidB =
wgroup "euclid" $ do
columns
func "euclid" (euclid (head ecA1) (head $ drop 1 ecA1)) ecA2
func "euclidFull" (euclidFull (head ecA1) (head $ drop 1 ecA1) ecA2) ecA2
func "euclidBool" (_euclidBool 1) 100000
12 changes: 6 additions & 6 deletions bench/Speed/Main.hs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
module Main where

import Criterion.Main
import Tidal.PatternB
import Criterion.Main
import Tidal.CoreB
import Tidal.PatternB
import Tidal.UIB

patternBs :: [IO ()]
patternBs :: [IO ()]
patternBs = defaultMain <$> [withQueryTimeB, withQueryArcB, withResultArcB, withQueryTimeB, subArcB]

coreBs :: [IO ()]
coreBs :: [IO ()]
coreBs = defaultMain <$> [fromListB, stackB, appendB, concatB, _fastB]

uiBs :: [IO ()]
uiBs = defaultMain <$> [euclidB, fixB]

main :: IO ()
main = do
_ <- sequence coreBs
main = do
_ <- sequence coreBs
_ <- sequence patternBs
_ <- sequence uiBs
return ()
82 changes: 46 additions & 36 deletions bench/Speed/Tidal/CoreB.hs
Original file line number Diff line number Diff line change
@@ -1,50 +1,60 @@
module Tidal.CoreB where
module Tidal.CoreB where

import Criterion.Main
import Tidal.Inputs
import Criterion.Main
import Sound.Tidal.Core
import Sound.Tidal.Pattern
import Sound.Tidal.Core
import Tidal.Inputs

_fastB :: [Benchmark]
_fastB =
[ bgroup "_fast" [
bench "_fast < 0" $ whnf (_fast (-2)) pattApp2
, bench "_fast > 0" $ whnf (_fast (toTime $ 10^6)) (cat catPattBig) ]
_fastB =
[ bgroup
"_fast"
[ bench "_fast < 0" $ whnf (_fast (-2)) pattApp2,
bench "_fast > 0" $ whnf (_fast (toTime $ 10 ^ 6)) (cat catPattBig)
]
]

concatB :: [Benchmark]
concatB =
[ bgroup "concat" [
bench "fastCat 10^3" $ whnf fastCat catPattSmall
, bench "fastCat 10^4" $ whnf fastCat catPattMed
, bench "fastCat 10^5" $ whnf fastCat catPattMedB
, bench "fastCat 10^6" $ whnf fastCat catPattBig
, bench "timeCat 10^5" $ whnf timeCat timeCatMed
, bench "timeCat 10^6" $ whnf timeCat timeCatBig ]
concatB :: [Benchmark]
concatB =
[ bgroup
"concat"
[ bench "fastCat 10^3" $ whnf fastCat catPattSmall,
bench "fastCat 10^4" $ whnf fastCat catPattMed,
bench "fastCat 10^5" $ whnf fastCat catPattMedB,
bench "fastCat 10^6" $ whnf fastCat catPattBig,
bench "timeCat 10^5" $ whnf timeCat timeCatMed,
bench "timeCat 10^6" $ whnf timeCat timeCatBig
]
]

fromListB :: [Benchmark]
fromListB =
[ bgroup "fromList" [
bench "fromList" $ whnf fromList xs6
, bench "fromList nf" $ nf fromList xs6
, bench "fastFromList 10^3" $ whnf fastFromList xs3
, bench "fastFromList 10^4" $ whnf fastFromList xs4
, bench "fastFromList 10^5" $ whnf fastFromList xs5
, bench "fastFromList 10^6" $ whnf fastFromList xs6
, bench "fastFromList 10^6 nf" $ nf fastFromList xs6 ]
fromListB =
[ bgroup
"fromList"
[ bench "fromList" $ whnf fromList xs6,
bench "fromList nf" $ nf fromList xs6,
bench "fastFromList 10^3" $ whnf fastFromList xs3,
bench "fastFromList 10^4" $ whnf fastFromList xs4,
bench "fastFromList 10^5" $ whnf fastFromList xs5,
bench "fastFromList 10^6" $ whnf fastFromList xs6,
bench "fastFromList 10^6 nf" $ nf fastFromList xs6
]
]

appendB :: [Benchmark]
appendB =
[ bgroup "append" [
bench "append" $ whnf (append pattApp1) pattApp2
, bench "fastAppend" $ whnf (fastAppend pattApp1) pattApp2 ]
appendB :: [Benchmark]
appendB =
[ bgroup
"append"
[ bench "append" $ whnf (append pattApp1) pattApp2,
bench "fastAppend" $ whnf (fastAppend pattApp1) pattApp2
]
]

stackB :: [Benchmark]
stackB =
[ bgroup "stack" [
bench "overlay" $ whnf (overlay pattApp1) pattApp2
, bench "stack" $ whnf stack catPattBig ]
stackB :: [Benchmark]
stackB =
[ bgroup
"stack"
[ bench "overlay" $ whnf (overlay pattApp1) pattApp2,
bench "stack" $ whnf stack catPattBig
]
]
39 changes: 20 additions & 19 deletions bench/Speed/Tidal/Inputs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@

module Tidal.Inputs where

import Sound.Tidal.Pattern
import Sound.Tidal.Core
import Sound.Tidal.ParseBP()
import Sound.Tidal.Params
import Sound.Tidal.ParseBP ()
import Sound.Tidal.Pattern
import Sound.Tidal.UI

{- Pattern inputs -}
xs3 :: [Time]
xs3 = [1..10000]
xs3 = [1 .. 10000]

xs4 :: [Time]
xs4 = [1..100000]
xs4 = [1 .. 100000]

xs5 :: [Time]
xs5 = [1..1000000]
xs5 = [1 .. 1000000]

xs6 :: [Time]
xs6 = [1..10000000]
xs6 = [1 .. 10000000]

xsA :: [Time]
xsA = [500000..1500000]
xsA = [500000 .. 1500000]

catPattSmall :: [Pattern Time]
catPattSmall = pure <$> xs3
Expand Down Expand Up @@ -67,18 +67,19 @@ fixArg1 = pF "cc64" 1

fixArg2 :: ControlPattern
fixArg2 =
fix ( # crush 4 ) (pF "cc65" 1)
-- $ fix ( stut' 4 (0.125/4) ( + up "1" )) (pF "cc66" 1)
$ fix ( |*| speed "-1" ) (pF "cc67" 1)
$ fix ( (# delaytime 0.125).(# delay 0.5)) (pF "cc68" 1)
$ fix ( # coarse 12) (pF "cc69" 1)
$ s "[808bd:1(3,8), dr(7,8)]"
# pF "cc64" (cF 0 "64")
# pF "cc65" (cF 0 "65")
# pF "cc66" (cF 0 "66")
# pF "cc67" (cF 0 "67")
# pF "cc68" (cF 0 "68")
#  pF "cc69" (cF 0 "69")
fix (# crush 4) (pF "cc65" 1)
-- fix ( stut' 4 (0.125/4) ( + up "1" )) (pF "cc66" 1)
$
fix (|*| speed "-1") (pF "cc67" 1) $
fix ((# delaytime 0.125) . (# delay 0.5)) (pF "cc68" 1) $
fix (# coarse 12) (pF "cc69" 1) $
s "[808bd:1(3,8), dr(7,8)]"
# pF "cc64" (cF 0 "64")
# pF "cc65" (cF 0 "65")
# pF "cc66" (cF 0 "66")
# pF "cc67" (cF 0 "67")
# pF "cc68" (cF 0 "68")
# pF "cc69" (cF 0 "69")

{- Euclid inputs -}
ecA1 :: [Pattern Int]
Expand Down
Loading