Skip to content

Commit e372bf5

Browse files
authored
Merge pull request #18 from morphismtech/polyadic-branch2
Polyadic branch2
2 parents 8f2ead5 + d8f53ee commit e372bf5

File tree

13 files changed

+147
-141
lines changed

13 files changed

+147
-141
lines changed

TODO

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ x Monadic interface ala Lysxia
55
More Tests
66
Parsec profunctor with either TokenTest or NonTerminal errors ala Leijen
77
Categoric interface with diid
8-
Arrowic?
98
Read Chomsky
109
Documents
1110
Announcement

distributors.cabal

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,16 @@ library
3333
Control.Lens.Grammar
3434
Control.Lens.Grammar.BackusNaur
3535
Control.Lens.Grammar.Boole
36+
Control.Lens.Grammar.Do
3637
Control.Lens.Grammar.Kleene
3738
Control.Lens.Grammar.Symbol
3839
Control.Lens.Grammar.Token
3940
Control.Lens.Grate
40-
Control.Lens.Internal.Equator
4141
Control.Lens.Internal.NestedPrismTH
4242
Control.Lens.Monocle
4343
Control.Lens.PartialIso
4444
Control.Lens.Wither
4545
Data.Profunctor.Distributor
46-
Data.Profunctor.Do.Bond
47-
Data.Profunctor.Do.Polyadic.Bind
48-
Data.Profunctor.Do.Polyadic.Bond
4946
Data.Profunctor.Filtrator
5047
Data.Profunctor.Grammar
5148
Data.Profunctor.Monadic

src/Control/Lens/Bifocal.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module Control.Lens.Bifocal
3434

3535
import Control.Applicative
3636
import Control.Lens
37-
import Control.Lens.Internal.Equator
3837
import Control.Lens.Internal.Profunctor
3938
import Control.Lens.PartialIso
4039
import Data.Profunctor
@@ -137,7 +136,7 @@ chained assoc binPat nilPat = unwrapPafb . chain assoc binPat nilPat noSep . Wra
137136
withBifocal
138137
:: (Alternative f, Filterable f)
139138
=> ABifocal s t a b -> ((s -> Maybe a) -> f b) -> f t
140-
withBifocal bif = unBinocular (catMaybes (bif (Just <$> equate)))
139+
withBifocal bif = unBinocular (catMaybes (bif (Just <$> Binocular ($ Just))))
141140

142141
{- | `Binocular` provides an efficient
143142
concrete representation of `Bifocal`s. -}
@@ -146,8 +145,6 @@ newtype Binocular a b s t = Binocular
146145
:: forall f. (Alternative f, Filterable f)
147146
=> ((s -> Maybe a) -> f b) -> f t
148147
}
149-
instance Equator a b (Binocular a b) where
150-
equate = Binocular ($ Just)
151148
instance Profunctor (Binocular a b) where
152149
dimap f g (Binocular k) = Binocular $ fmap g . k . (. (. f))
153150
instance Functor (Binocular a b s) where fmap = rmap

src/Control/Lens/Diopter.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ module Control.Lens.Diopter
2525
) where
2626

2727
import Control.Lens
28-
import Control.Lens.Internal.Equator
2928
import Control.Lens.Internal.Profunctor
3029
import Data.Profunctor.Distributor
3130
import Data.Void
@@ -56,7 +55,7 @@ withDiopter
5655
:: ADiopter s t a b
5756
-> (forall h. Homogeneous h => (s -> h a) -> (h b -> t) -> r)
5857
-> r
59-
withDiopter dio k = case runIdentity <$> dio (Identity <$> equate) of
58+
withDiopter dio k = case runIdentity <$> dio (Identity <$> Dioptrice Par1 unPar1) of
6059
Dioptrice f g -> k f g
6160

6261
{- | Action of `ADiopter` on `Distributor`s. -}
@@ -95,8 +94,6 @@ data Dioptrice a b s t where
9594
=> (s -> h a)
9695
-> (h b -> t)
9796
-> Dioptrice a b s t
98-
instance Equator a b (Dioptrice a b) where
99-
equate = Dioptrice Par1 unPar1
10097
instance Profunctor (Dioptrice a b) where
10198
dimap f g (Dioptrice sa bt) = Dioptrice (sa . f) (g . bt)
10299
instance Functor (Dioptrice a b s) where fmap = rmap
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{-|
2-
Module : Data.Profunctor.Do.Bond
2+
Module : Control.Lens.Grammar
33
Description : monadic pair-bonding do-notation
44
Copyright : (C) 2025 - Eitan Chatav
55
License : BSD-style (see the file LICENSE)
@@ -8,7 +8,7 @@ Stability : provisional
88
Portability : non-portable
99
-}
1010

11-
module Data.Profunctor.Do.Bond
11+
module Control.Lens.Grammar.Do
1212
( -- *
1313
(>>=)
1414
, (>>)
@@ -17,16 +17,16 @@ module Data.Profunctor.Do.Bond
1717
, return
1818
) where
1919

20-
import Control.Lens (Optic)
20+
import Control.Applicative hiding ((<$>))
21+
import Control.Lens
22+
import Control.Lens.Grammar.BackusNaur
2123
import Control.Monad (join)
22-
import Data.Profunctor (Profunctor (dimap))
23-
import Data.Profunctor.Do.Polyadic.Bind (fail)
24-
import Data.Profunctor.Monadic (Monadic (liftP, bondM))
25-
import Prelude (Applicative (pure), const, fmap, flip, fst, snd, return, (.))
24+
import Data.Profunctor.Monadic
25+
import Prelude hiding ((>>=), (>>), (<$>), fail)
2626

2727
(>>=) :: Monadic m p => p m a a -> (a -> p m b c) -> p m (a,b) (a,c)
2828
infixl 1 >>=
29-
(>>=) = flip bondM
29+
(>>=) = bondM
3030

3131
(>>) :: Monadic m p => p m () () -> p m b c -> p m b c
3232
infixl 1 >>
@@ -38,3 +38,6 @@ x >> y = dimap ((),) snd (x >>= const y)
3838
-> p m (a,()) (b,()) -> p m s t
3939
infixl 4 <$>
4040
f <$> x = join (fmap liftP (f (dimap (,()) (pure . fst) x)))
41+
42+
fail :: (Alternative f, BackusNaurForm (f a)) => String -> f a
43+
fail msg = rule msg empty

src/Control/Lens/Grate.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ module Control.Lens.Grate
3030
, Grating (..)
3131
) where
3232

33-
import Control.Lens.Internal.Equator
3433
import Data.Distributive
3534
import Data.Function
3635
import Data.Functor.Identity
@@ -78,7 +77,7 @@ cloneGrate = grate . withGrate
7877

7978
{- | Run `AGrate`. -}
8079
withGrate :: AGrate s t a b -> ((s -> a) -> b) -> t
81-
withGrate grt = runGrating $ runIdentity <$> grt (Identity <$> equate)
80+
withGrate grt = runGrating $ runIdentity <$> grt (Identity <$> Grating ($ id))
8281

8382
{- | Distribute over a `Closed` `Profunctor`. -}
8483
distributing
@@ -109,8 +108,6 @@ instance Functor (Grating a b s) where fmap = fmapRep
109108
instance Applicative (Grating a b s) where
110109
pure = pureRep
111110
(<*>) = apRep
112-
instance Equator a b (Grating a b) where
113-
equate = Grating ($ id)
114111
instance Distributive (Grating a b s) where
115112
distribute = distributeRep
116113
collect = collectRep

src/Control/Lens/Internal/Equator.hs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Control/Lens/Monocle.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ module Control.Lens.Monocle
2727
) where
2828

2929
import Control.Lens hiding (Traversing)
30-
import Control.Lens.Internal.Equator
3130
import Control.Lens.Internal.Profunctor
3231
import Data.Distributive
3332
import Data.Profunctor.Monoidal
@@ -77,14 +76,12 @@ forevered = unwrapPafb . foreverP . WrapPafb
7776

7877
{- | Run `AMonocle` over an `Applicative`. -}
7978
withMonocle :: Applicative f => AMonocle s t a b -> ((s -> a) -> f b) -> f t
80-
withMonocle mon = unMonocular (runIdentity <$> mon (Identity <$> equate))
79+
withMonocle mon = unMonocular (runIdentity <$> mon (Identity <$> Monocular ($ id)))
8180

8281
{- | `Monocular` provides an efficient
8382
concrete representation of `Monocle`s. -}
8483
newtype Monocular a b s t = Monocular
8584
{unMonocular :: forall f. Applicative f => ((s -> a) -> f b) -> f t}
86-
instance Equator a b (Monocular a b) where
87-
equate = Monocular ($ id)
8885
instance Profunctor (Monocular a b) where
8986
dimap f g (Monocular k) =
9087
Monocular (fmap g . k . (. (. f)))

src/Data/Profunctor/Do/Polyadic/Bind.hs

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/Data/Profunctor/Do/Polyadic/Bond.hs

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)