summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore/should_compile/T17429.hs
blob: bd01c140ff69142db58caf0092d0cd1c4c3bd0fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeFamilies #-}

module T17429
  ( zoomAcceptor
  ) where

type Zoom m = ( m ~ Emitter Int )

zoomAcceptor :: Zoom m => Emitter w a -> m w
zoomAcceptor = fmap id . zoomEmitter

zoomEmitter :: Emitter w a -> Emitter b w
zoomEmitter (Emitter go) =
  Emitter $ const ([], fst $ go ())

newtype Emitter w a = Emitter (() -> ([w], [a]))

instance Functor (Emitter w) where
  fmap f (Emitter go) = Emitter mapped
    where
    {-# INLINE mapped #-}
    mapped _ = fmap f <$> go ()