@@ -194,21 +194,26 @@ instance (Monad m, Functor f, Ord1 m, Ord1 f) => Ord1 (Stream f m) where
194194-- like producing @m String@, except that a @ShowSWrapper@ can be
195195-- shown at any precedence. So the 'Show' instance for @m@ can show
196196-- the contents at the correct precedence.
197- instance (Monad m , Show r , Show (m ShowSWrapper ), Show (f ( Stream f m r )) )
197+ instance (Monad m , Functor f , Show (m ShowSWrapper ), Show (f ShowSWrapper ), Show r )
198198 => Show (Stream f m r ) where
199- showsPrec p xs = showParen (p > 10 ) $
200- showString " Effect " . (showsPrec 11 $
201- flip fmap (inspect xs) $ \ front ->
202- SS $ \ d -> showParen (d > 10 ) $
203- case front of
204- Left r -> showString " Return " . showsPrec 11 r
205- Right f -> showString " Step " . showsPrec 11 f)
199+ showsPrec = liftShowsPrec' showsPrec showList
206200
207201#if MIN_VERSION_base(4,9,0)
208202
209203instance (Monad m , Functor f , Show (m ShowSWrapper ), Show (f ShowSWrapper ))
210204 => Show1 (Stream f m ) where
211- liftShowsPrec sp sl p xs = showParen (p > 10 ) $
205+ liftShowsPrec = liftShowsPrec'
206+
207+ #endif
208+
209+ liftShowsPrec'
210+ :: (Monad m , Functor f , Show (m ShowSWrapper ), Show (f ShowSWrapper ))
211+ => (Int -> a -> ShowS )
212+ -> ([a ] -> ShowS )
213+ -> Int
214+ -> Stream f m a
215+ -> ShowS
216+ liftShowsPrec' sp sl p xs = showParen (p > 10 ) $
212217 showString " Effect " . (showsPrec 11 $
213218 flip fmap (inspect xs) $ \ front ->
214219 SS $ \ d -> showParen (d > 10 ) $
@@ -217,8 +222,6 @@ instance (Monad m, Functor f, Show (m ShowSWrapper), Show (f ShowSWrapper))
217222 Right f -> showString " Step " .
218223 showsPrec 11 (fmap (SS . (\ str i -> liftShowsPrec sp sl i str)) f))
219224
220- #endif
221-
222225newtype ShowSWrapper = SS (Int -> ShowS )
223226instance Show ShowSWrapper where
224227 showsPrec p (SS s) = s p
0 commit comments