Skip to content

Commit

Permalink
Updates for 0.11 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
natefaubion authored Apr 11, 2017
1 parent ced425e commit 80ee558
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 66 deletions.
11 changes: 5 additions & 6 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
"package.json"
],
"dependencies": {
"purescript-fixed-points": "^3.0.0",
"purescript-free": "^3.2.0",
"purescript-transformers": "^2.0.2",
"purescript-profunctor": "^2.0.0"
"purescript-fixed-points": "^4.0.0",
"purescript-free": "^4.0.0",
"purescript-transformers": "^3.0.0",
"purescript-profunctor": "^3.0.0"
},
"devDependencies": {
"purescript-console": "^2.0.0"
"purescript-console": "^3.0.0"
}

}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"test": "pulp test -- --censor-lib --strict"
},
"devDependencies": {
"pulp": "^10.0.0",
"purescript": "^0.10.3",
"purescript-psa": "^0.4.0",
"pulp": "^11.0.0",
"purescript": "^0.11.3",
"purescript-psa": "^0.5.0",
"rimraf": "^2.5.4"
}
}
21 changes: 13 additions & 8 deletions src/Matryoshka/DistributiveLaw.purs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ import Matryoshka.Coalgebra (Coalgebra)

type DistributiveLaw f g = a. f (g a) g (f a)

distApplicative f g. (Traversable f, Applicative g) DistributiveLaw f g
distApplicative f g. Traversable f Applicative g DistributiveLaw f g
distApplicative = sequence

distDistributive f g. (Traversable f, Distributive g) DistributiveLaw f g
distDistributive f g. Traversable f Distributive g DistributiveLaw f g
distDistributive = distribute

distCata f. Functor f DistributiveLaw f Identity
Expand All @@ -53,7 +53,8 @@ distPara = distZygo embed

distParaT
t f w
. (Corecursive t f, Comonad w)
. Corecursive t f
Comonad w
DistributiveLaw f w
DistributiveLaw f (EnvT t w)
distParaT = distZygoT embed
Expand All @@ -63,7 +64,8 @@ distZygo g m = Tuple (g (map fst m)) (map snd m)

distZygoT
f w a
. (Functor f, Comonad w)
. Functor f
Comonad w
Algebra f a
DistributiveLaw f w
DistributiveLaw f (EnvT a w)
Expand All @@ -75,10 +77,11 @@ distHisto = distGHisto id

distGHisto
f h
. (Functor f, Functor h)
. Functor f
Functor h
DistributiveLaw f h
DistributiveLaw f (Cofree h)
distGHisto k x = unfoldCofree x (map extract) (k <<< map tail)
distGHisto k = unfoldCofree (map extract) (k <<< map tail)

distAna f. Functor f DistributiveLaw Identity f
distAna = map wrap <<< unwrap
Expand All @@ -91,7 +94,8 @@ distGApo f = either (map Left <<< f) (map Right)

distGApoT
f m a
. (Functor f, Functor m)
. Functor f
Functor m
Coalgebra f a
DistributiveLaw m f
DistributiveLaw (ExceptT a m) f
Expand All @@ -102,7 +106,8 @@ distFutu = distGFutu id

distGFutu
f h
. (Functor f, Functor h)
. Functor f
Functor h
DistributiveLaw h f
DistributiveLaw (Free h) f
distGFutu k f = case resume f of
Expand Down
86 changes: 61 additions & 25 deletions src/Matryoshka/Fold.purs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ cata f = go

cataM
t f m a
. (Recursive t f, Monad m, Traversable f)
. Recursive t f
Monad m
Traversable f
AlgebraM m f a
t
m a
Expand All @@ -54,7 +56,8 @@ cataM f = go

gcata
t f w a
. (Recursive t f, Comonad w)
. Recursive t f
Comonad w
DistributiveLaw f w
GAlgebra w f a
t
Expand All @@ -65,7 +68,11 @@ gcata k g = g <<< extract <<< go

gcataM
t f w m a
. (Recursive t f, Monad m, Comonad w, Traversable f, Traversable w)
. Recursive t f
Monad m
Comonad w
Traversable f
Traversable w
DistributiveLaw f w
GAlgebraM w m f a
t
Expand All @@ -76,7 +83,8 @@ gcataM k g = g <<< extract <=< loop

elgotCata
t f w a
. (Recursive t f, Comonad w)
. Recursive t f
Comonad w
DistributiveLaw f w
ElgotAlgebra w f a
t
Expand All @@ -87,7 +95,8 @@ elgotCata k g = g <<< go

transCata
t f u g
. (Recursive t f, Corecursive u g)
. Recursive t f
Corecursive u g
Transform u f g
t
u
Expand All @@ -97,7 +106,8 @@ transCata f = go

transCataT
t f
. (Recursive t f, Corecursive t f)
. Recursive t f
Corecursive t f
(t t)
t
t
Expand All @@ -107,7 +117,10 @@ transCataT f = go

transCataM
t f u g m
. (Recursive t f, Corecursive u g, Monad m, Traversable f)
. Recursive t f
Corecursive u g
Monad m
Traversable f
TransformM m u f g
t
m u
Expand All @@ -117,7 +130,10 @@ transCataM f = go

transCataTM
t f m
. (Recursive t f, Corecursive t f, Monad m, Traversable f)
. Recursive t f
Corecursive t f
Monad m
Traversable f
(t m t)
t
m t
Expand All @@ -127,7 +143,8 @@ transCataTM f = go

topDownCata
t f a
. (Recursive t f, Corecursive t f)
. Recursive t f
Corecursive t f
(a t Tuple a t)
a
t
Expand All @@ -139,7 +156,10 @@ topDownCata f = go

topDownCataM
t f m a
. (Recursive t f, Corecursive t f, Monad m, Traversable f)
. Recursive t f
Corecursive t f
Monad m
Traversable f
(a t m (Tuple a t))
a
t
Expand All @@ -151,7 +171,8 @@ topDownCataM f = go

prepro
t f a
. (Recursive t f, Corecursive t f)
. Recursive t f
Corecursive t f
(f ~> f)
Algebra f a
t
Expand All @@ -162,7 +183,9 @@ prepro f g = go

gprepro
t f w a
. (Recursive t f, Corecursive t f, Comonad w)
. Recursive t f
Corecursive t f
Comonad w
DistributiveLaw f w
(f ~> f)
GAlgebra w f a
Expand All @@ -174,7 +197,9 @@ gprepro f g h = extract <<< go

transPrepro
t f u g
. (Recursive t f, Corecursive t f, Corecursive u g)
. Recursive t f
Corecursive t f
Corecursive u g
(f ~> f)
Transform u f g
t
Expand All @@ -191,7 +216,9 @@ para f = go

paraM
t f m a
. (Recursive t f, Monad m, Traversable f)
. Recursive t f
Monad m
Traversable f
GAlgebraM (Tuple t) m f a
t
m a
Expand All @@ -201,7 +228,9 @@ paraM f = go

gpara
t f w a
. (Recursive t f, Corecursive t f, Comonad w)
. Recursive t f
Corecursive t f
Comonad w
DistributiveLaw f w
GAlgebra (EnvT t w) f a
t
Expand All @@ -215,7 +244,8 @@ elgotPara f = go

transPara
t f u g
. (Recursive t f, Corecursive u g)
. Recursive t f
Corecursive u g
AlgebraicGTransform (Tuple t) u f g
t
u
Expand All @@ -225,7 +255,8 @@ transPara f = go

transParaT
t f
. (Recursive t f, Corecursive t f)
. Recursive t f
Corecursive t f
(t t t)
t
t
Expand All @@ -244,7 +275,8 @@ zygo = gcata <<< distZygo

gzygo
t f w a b
. (Recursive t f, Comonad w)
. Recursive t f
Comonad w
Algebra f b
DistributiveLaw f w
GAlgebra (EnvT b w) f a
Expand All @@ -263,7 +295,8 @@ elgotZygo = elgotCata <<< distZygo

gElgotZygo
t f w a b
. (Recursive t f, Comonad w)
. Recursive t f
Comonad w
Algebra f b
DistributiveLaw f w
ElgotAlgebra (EnvT b w) f a
Expand Down Expand Up @@ -292,7 +325,8 @@ histo = gcata distHisto

ghisto
t f h a
. (Recursive t f, Functor h)
. Recursive t f
Functor h
DistributiveLaw f h
GAlgebra (Cofree h) f a
t
Expand Down Expand Up @@ -322,7 +356,9 @@ annotateTopDown f z = go

annotateTopDownM
t f m a
. (Recursive t f, Monad m, Traversable f)
. Recursive t f
Monad m
Traversable f
(a f t m a)
a
t
Expand All @@ -333,14 +369,14 @@ annotateTopDownM f z = go
let ft = project t
in (flip map (traverse go ft) <<< mkCofree) =<< f z ft

isLeaf t f. (Recursive t f, Foldable f) t Boolean
isLeaf t f. Recursive t f Foldable f t Boolean
isLeaf t = alaF Disj foldMap (const true) (project t)

children t f. (Recursive t f, Foldable f) t List t
children t f. Recursive t f Foldable f t List t
children = foldMap pure <<< project

universe t f. (Recursive t f, Foldable f) t List t
universe t f. Recursive t f Foldable f t List t
universe t = universe =<< children t

lambek t f. (Recursive t f, Corecursive t f) t f t
lambek t f. Recursive t f Corecursive t f t f t
lambek = cata (map embed)
Loading

0 comments on commit 80ee558

Please sign in to comment.