@@ -6,6 +6,7 @@ module Control.Ether.Optic
66 , view
77 , over
88 , HList(..)
9+ , KindOf
910 ) where
1011
1112import Control.Applicative
@@ -18,7 +19,9 @@ import Data.Traversable
1819import Language.Haskell.TH
1920import Data.Coerce
2021
21−type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
22+type LensLike f s t a b = (a -> f b) -> s -> f t
23+
24+type Lens s t a b = forall f. Functor f => LensLike f s t a b
2225
2326type Lens' s a = Lens s s a a
2427
@@ -29,17 +32,12 @@ instance HasLens a a a where
2932 lensOf = id
3033 {-# INLINE lensOf #-}
3134
32−(#.) :: Coercible c b => (b -> c) -> (a -> b) -> (a -> c)
33−(#.) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b
34−
35−infixr 9 #.
36−
37−view :: Lens s t a b -> s -> a
38−view l = getConst #. l Const
35+view :: LensLike (Const a) s t a b -> s -> a
36+view l = coerce (l Const)
3937{-# INLINE view #-}
4038
41−over :: Lens s t a b -> (a -> b) -> s -> t
42−over l f = runIdentity #. l (Identity #. f)
39+over :: LensLike Identity s t a b -> (a -> b) -> s -> t
40+over = coerce
4341{-# INLINE over #-}
4442
4543data HList xs where
@@ -54,11 +52,13 @@ type family Tags (p :: K.Type) :: HList (TagsK p)
5452return []
5553
5654type instance TagsK () = '[]
55+type instance TagsK (Tagged t a) = '[KindOf t]
5756type instance TagsK (Tagged t0 a, Tagged t1 b) = '[KindOf t0, KindOf t1]
5857
5958return []
6059
6160type instance Tags () = 'HNil
61+type instance Tags (Tagged t a) = 'HCons t 'HNil
6262type instance Tags (Tagged t0 a, Tagged t1 b) = 'HCons t0 ('HCons t1 'HNil)
6363
6464do