11{-# LANGUAGE FlexibleContexts #-}
2- {-# LANGUAGE FlexibleInstances #-}
32{-# LANGUAGE KindSignatures #-}
4- {-# LANGUAGE LambdaCase #-}
53{-# LANGUAGE LinearTypes #-}
64{-# LANGUAGE MultiParamTypeClasses #-}
75{-# LANGUAGE NoImplicitPrelude #-}
@@ -14,19 +12,13 @@ module Data.Profunctor.Linear
1412 , Strong (.. )
1513 , Wandering (.. )
1614 , LinearArrow (.. ), getLA
17- , Kleisli (.. )
18- , LKleisli (.. )
19- , CoLKleisli (.. )
2015 , Exchange (.. )
2116 ) where
2217
23- import qualified Control.Monad.Linear as Control
2418import qualified Data.Functor.Linear as Data
2519import Data.Bifunctor.Linear hiding (first , second )
26- import Data.Functor.Const
2720import Prelude.Linear
2821import Data.Void
29- import qualified Prelude
3022
3123-- TODO: write laws
3224
@@ -69,7 +61,6 @@ class (Strong (,) () arr, Strong Either Void arr) => Wandering arr where
6961
7062newtype LinearArrow a b = LA (a ->. b )
7163-- | Temporary deconstructor since inference doesn't get it right
72- -- TODO: maybe use TH to automatically write things like this?
7364getLA :: LinearArrow a b ->. a ->. b
7465getLA (LA f) = f
7566
@@ -84,37 +75,6 @@ instance Strong Either Void LinearArrow where
8475 first (LA f) = LA $ either (Left . f) Right
8576 second (LA g) = LA $ either Left (Right . g)
8677
87- newtype Kleisli m a b = Kleisli { runKleisli :: a -> m b }
88-
89- instance Prelude. Functor f => Profunctor (Kleisli f ) where
90- dimap f g (Kleisli h) = Kleisli (\ x -> forget g Prelude. <$> h (f x))
91-
92- instance Prelude. Functor f => Strong (,) () (Kleisli f ) where
93- first (Kleisli f) = Kleisli (\ (a,b) -> (,b) Prelude. <$> f a)
94- second (Kleisli g) = Kleisli (\ (a,b) -> (a,) Prelude. <$> g b)
95-
96- instance Prelude. Applicative f => Strong Either Void (Kleisli f ) where
97- first (Kleisli f) = Kleisli $ \ case
98- Left x -> Prelude. fmap Left (f x)
99- Right y -> Prelude. pure (Right y)
100-
101-
102- newtype LKleisli m a b = LKleisli { runLKleisli :: a ->. m b }
103-
104- instance Data. Functor f => Profunctor (LKleisli f ) where
105- dimap f g (LKleisli h) = LKleisli (Data. fmap g . h . f)
106-
107- instance Control. Functor f => Strong (,) () (LKleisli f ) where
108- first (LKleisli f) = LKleisli (\ (a,b) -> (,b) Control. <$> f a)
109- second (LKleisli g) = LKleisli (\ (a,b) -> (a,) Control. <$> g b)
110-
111- instance Control. Applicative f => Strong Either Void (LKleisli f ) where
112- first (LKleisli f) = LKleisli (either (Data. fmap Left . f) (Control. pure . Right ))
113- second (LKleisli g) = LKleisli (either (Control. pure . Left ) (Data. fmap Right . g))
114-
115- instance Control. Applicative f => Wandering (LKleisli f ) where
116- wander (LKleisli f) = LKleisli (Data. traverse f)
117-
11878instance Profunctor (-> ) where
11979 dimap f g h x = g (h (f x))
12080instance Strong (,) () (-> ) where
@@ -123,19 +83,6 @@ instance Strong Either Void (->) where
12383 first f (Left x) = Left (f x)
12484 first _ (Right y) = Right y
12585
126- -- XXX: Since CoLKleisli has uses, it might be better to replace all this
127- -- with a Bif-like structure...
128- --
129- newtype CoLKleisli w a b = CoLKleisli { runCoLKleisli :: w a ->. b }
130-
131- instance Data. Functor f => Profunctor (CoLKleisli f ) where
132- dimap f g (CoLKleisli h) = CoLKleisli (g . h . Data. fmap f)
133-
134- -- instance of a more general idea, but this will do for now
135- instance Strong Either Void (CoLKleisli (Const x )) where
136- first (CoLKleisli f) = CoLKleisli (\ (Const x) -> Left (f (Const x)))
137-
13886data Exchange a b s t = Exchange (s ->. a ) (b ->. t )
13987instance Profunctor (Exchange a b ) where
14088 dimap f g (Exchange p q) = Exchange (p . f) (g . q)
141-
0 commit comments