@@ -159,3 +159,31 @@ data Exchange a b s t = Exchange (s ->. a) (b ->. t)
159159instance Profunctor (Exchange a b ) where
160160 dimap f g (Exchange p q) = Exchange (p . f) (g . q)
161161
162+ data Top = forall x . Top x
163+ instance Show Top where
164+ show (Top _) = " something"
165+ instance Control. Functor (Const (Top , a )) where
166+ fmap f (Const (Top t, x)) = Const (Top (t,f), x)
167+ instance Monoid a => Control. Applicative (Const (Top , a )) where
168+ pure x = Const (Top x, mempty )
169+ Const (Top a, x) <*> Const (Top b, y) = Const (Top (a,b), x <> y)
170+
171+ -- TODO: pick a more sensible name for this
172+ newtype MyFunctor a b t = MyFunctor (b ->. (a , t ))
173+ runMyFunctor :: MyFunctor a b t ->. b ->. (a , t )
174+ runMyFunctor (MyFunctor f) = f
175+
176+ instance Data. Functor (MyFunctor a b ) where
177+ fmap f (MyFunctor g) = MyFunctor (getLA (second (LA f)) . g)
178+ instance Control. Functor (MyFunctor a b ) where
179+ fmap f (MyFunctor g) = MyFunctor (thing f . g)
180+ where thing :: (c ->. d ) ->. (e , c ) ->. (e , d )
181+ thing k (x,y) = (x, k y)
182+
183+ instance Prelude. Semigroup Top where
184+ Top x <> Top y = Top (x,y)
185+ instance Semigroup Top where
186+ Top x <> Top y = Top (x,y)
187+ instance Prelude. Monoid Top where
188+ mempty = Top ()
189+ instance Monoid Top where
0 commit comments