Skip to content

Commit 32db796

Browse files
Introduce purs-tidy formatter (#25)
* Add purs-tidy formatter * Run purs-tidy
1 parent f102192 commit 32db796

File tree

16 files changed

+493
-471
lines changed

16 files changed

+493
-471
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 (#25 by @thomashoneyman)
1415
- Updated dependencies to clear build errors related to unlisted dependencies (#24 by @flounders)
1516

1617
## [v0.5.0](https://github.com/purescript-contrib/purescript-matryoshka/releases/tag/v0.5.0) - 2021-02-26

src/Matryoshka/Algebra.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ limitations under the License.
1717
module Matryoshka.Algebra where
1818

1919
type GAlgebra :: (Type -> Type) -> (Type -> Type) -> Type -> Type
20-
type GAlgebra w f a = f (w a) a
20+
type GAlgebra w f a = f (w a) -> a
2121

2222
type GAlgebraM :: (Type -> Type) -> (Type -> Type) -> (Type -> Type) -> Type -> Type
23-
type GAlgebraM w m f a = f (w a) m a
23+
type GAlgebraM w m f a = f (w a) -> m a
2424

25-
type Algebra f a = f a a
25+
type Algebra f a = f a -> a
2626

2727
type AlgebraM :: (Type -> Type) -> (Type -> Type) -> Type -> Type
28-
type AlgebraM m f a = f a m a
28+
type AlgebraM m f a = f a -> m a
2929

3030
type ElgotAlgebra :: (Type -> Type) -> (Type -> Type) -> Type -> Type
31-
type ElgotAlgebra w f a = w (f a) a
31+
type ElgotAlgebra w f a = w (f a) -> a

src/Matryoshka/Class/Corecursive.purs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ import Data.Tuple (Tuple(..))
2929

3030
import Matryoshka.Pattern.CoEnvT (CoEnvT(..))
3131

32-
class Functor f Corecursive t f | t f where
33-
embed f t t
32+
class Functor f <= Corecursive t f | t -> f where
33+
embed :: f t -> t
3434

35-
instance corecursiveMu Functor f Corecursive (Mu f) f where
35+
instance corecursiveMu :: Functor f => Corecursive (Mu f) f where
3636
embed = roll
3737

38-
instance corecursiveNu Functor f Corecursive (Nu f) f where
38+
instance corecursiveNu :: Functor f => Corecursive (Nu f) f where
3939
embed = flip unfold (map observe)
4040

41-
instance corecursiveFree Functor f Corecursive (Free f a) (CoEnvT a f) where
41+
instance corecursiveFree :: Functor f => Corecursive (Free f a) (CoEnvT a f) where
4242
embed (CoEnvT e) = either pure (join <<< liftF) e
4343

44-
instance corecursiveCofree Functor f Corecursive (Cofree f a) (EnvT a f) where
44+
instance corecursiveCofree :: Functor f => Corecursive (Cofree f a) (EnvT a f) where
4545
embed et = mkCofree (ask et) (lower et)
4646
where
4747
ask (EnvT (Tuple e _)) = e

src/Matryoshka/Class/Recursive.purs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ import Data.Tuple (Tuple(..))
2929

3030
import Matryoshka.Pattern.CoEnvT (CoEnvT(..))
3131

32-
class Functor f Recursive t f | t f where
33-
project t f t
32+
class Functor f <= Recursive t f | t -> f where
33+
project :: t -> f t
3434

35-
instance recursiveMu Functor f Recursive (Mu f) f where
35+
instance recursiveMu :: Functor f => Recursive (Mu f) f where
3636
project = unroll
3737

38-
instance recursiveNu Functor f Recursive (Nu f) f where
38+
instance recursiveNu :: Functor f => Recursive (Nu f) f where
3939
project = observe
4040

41-
instance recursiveFree Functor f Recursive (Free f a) (CoEnvT a f) where
41+
instance recursiveFree :: Functor f => Recursive (Free f a) (CoEnvT a f) where
4242
project = CoEnvT <<< either Right Left <<< resume
4343

44-
instance recursiveCofree Functor f Recursive (Cofree f a) (EnvT a f) where
44+
instance recursiveCofree :: Functor f => Recursive (Cofree f a) (EnvT a f) where
4545
project cf = EnvT $ Tuple (head cf) (tail cf)

src/Matryoshka/Coalgebra.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ limitations under the License.
1717
module Matryoshka.Coalgebra where
1818

1919
type GCoalgebra :: (Type -> Type) -> (Type -> Type) -> Type -> Type
20-
type GCoalgebra n f a = a f (n a)
20+
type GCoalgebra n f a = a -> f (n a)
2121

2222
type GCoalgebraM :: (Type -> Type) -> (Type -> Type) -> (Type -> Type) -> Type -> Type
23-
type GCoalgebraM n m f a = a m (f (n a))
23+
type GCoalgebraM n m f a = a -> m (f (n a))
2424

25-
type Coalgebra f a = a f a
25+
type Coalgebra f a = a -> f a
2626

2727
type CoalgebraM :: (Type -> Type) -> (Type -> Type) -> Type -> Type
28-
type CoalgebraM m f a = a m (f a)
28+
type CoalgebraM m f a = a -> m (f a)
2929

3030
type ElgotCoalgebra :: (Type -> Type) -> (Type -> Type) -> Type -> Type
31-
type ElgotCoalgebra e f a = a e (f a)
31+
type ElgotCoalgebra e f a = a -> e (f a)

src/Matryoshka/DistributiveLaw.purs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,79 +37,79 @@ import Matryoshka.Class.Corecursive (class Corecursive, embed)
3737
import Matryoshka.Class.Recursive (class Recursive, project)
3838
import Matryoshka.Coalgebra (Coalgebra)
3939

40-
type DistributiveLaw f g = a. f (g a) g (f a)
40+
type DistributiveLaw f g = forall a. f (g a) -> g (f a)
4141

42-
distApplicative f g. Traversable f Applicative g DistributiveLaw f g
42+
distApplicative :: forall f g. Traversable f => Applicative g => DistributiveLaw f g
4343
distApplicative = sequence
4444

45-
distDistributive f g. Traversable f Distributive g DistributiveLaw f g
45+
distDistributive :: forall f g. Traversable f => Distributive g => DistributiveLaw f g
4646
distDistributive = distribute
4747

48-
distCata f. Functor f DistributiveLaw f Identity
48+
distCata :: forall f. Functor f => DistributiveLaw f Identity
4949
distCata = wrap <<< map unwrap
5050

51-
distPara t f. Corecursive t f DistributiveLaw f (Tuple t)
51+
distPara :: forall t f. Corecursive t f => DistributiveLaw f (Tuple t)
5252
distPara = distZygo embed
5353

5454
distParaT
55-
t f w
56-
. Corecursive t f
57-
Comonad w
58-
DistributiveLaw f w
59-
DistributiveLaw f (EnvT t w)
55+
:: forall t f w
56+
. Corecursive t f
57+
=> Comonad w
58+
=> DistributiveLaw f w
59+
-> DistributiveLaw f (EnvT t w)
6060
distParaT = distZygoT embed
6161

62-
distZygo f a. Functor f Algebra f a DistributiveLaw f (Tuple a)
62+
distZygo :: forall f a. Functor f => Algebra f a -> DistributiveLaw f (Tuple a)
6363
distZygo g m = Tuple (g (map fst m)) (map snd m)
6464

6565
distZygoT
66-
f w a
67-
. Functor f
68-
Comonad w
69-
Algebra f a
70-
DistributiveLaw f w
71-
DistributiveLaw f (EnvT a w)
66+
:: forall f w a
67+
. Functor f
68+
=> Comonad w
69+
=> Algebra f a
70+
-> DistributiveLaw f w
71+
-> DistributiveLaw f (EnvT a w)
7272
distZygoT g k fe =
7373
EnvT $ Tuple (g (fst <<< runEnvT <$> fe)) (k (lower <$> fe))
7474

75-
distHisto f. Functor f DistributiveLaw f (Cofree f)
75+
distHisto :: forall f. Functor f => DistributiveLaw f (Cofree f)
7676
distHisto = distGHisto identity
7777

7878
distGHisto
79-
f h
80-
. Functor f
81-
Functor h
82-
DistributiveLaw f h
83-
DistributiveLaw f (Cofree h)
79+
:: forall f h
80+
. Functor f
81+
=> Functor h
82+
=> DistributiveLaw f h
83+
-> DistributiveLaw f (Cofree h)
8484
distGHisto k = unfoldCofree (map extract) (k <<< map tail)
8585

86-
distAna f. Functor f DistributiveLaw Identity f
86+
distAna :: forall f. Functor f => DistributiveLaw Identity f
8787
distAna = map wrap <<< unwrap
8888

89-
distApo t f. Recursive t f DistributiveLaw (Either t) f
89+
distApo :: forall t f. Recursive t f => DistributiveLaw (Either t) f
9090
distApo = distGApo project
9191

92-
distGApo f a. Functor f Coalgebra f a DistributiveLaw (Either a) f
92+
distGApo :: forall f a. Functor f => Coalgebra f a -> DistributiveLaw (Either a) f
9393
distGApo f = either (map Left <<< f) (map Right)
9494

9595
distGApoT
96-
f m a
97-
. Functor f
98-
Functor m
99-
Coalgebra f a
100-
DistributiveLaw m f
101-
DistributiveLaw (ExceptT a m) f
96+
:: forall f m a
97+
. Functor f
98+
=> Functor m
99+
=> Coalgebra f a
100+
-> DistributiveLaw m f
101+
-> DistributiveLaw (ExceptT a m) f
102102
distGApoT g k = map ExceptT <<< k <<< map (distGApo g) <<< runExceptT
103103

104-
distFutu f. Functor f DistributiveLaw (Free f) f
104+
distFutu :: forall f. Functor f => DistributiveLaw (Free f) f
105105
distFutu = distGFutu identity
106106

107107
distGFutu
108-
f h
109-
. Functor f
110-
Functor h
111-
DistributiveLaw h f
112-
DistributiveLaw (Free h) f
108+
:: forall f h
109+
. Functor f
110+
=> Functor h
111+
=> DistributiveLaw h f
112+
-> DistributiveLaw (Free h) f
113113
distGFutu k f = case resume f of
114-
Left as join <<< liftF <$> k (distGFutu k <$> as)
115-
Right b pure <$> b
114+
Left as -> join <<< liftF <$> k (distGFutu k <$> as)
115+
Right b -> pure <$> b

0 commit comments

Comments
 (0)