Skip to content

Commit 84f288d

Browse files
authored
Add Pretty instances for {4,5,6,7}-tuple) (#275)
The code was already there, so I just uncommented it. Resolves #243.
1 parent aeabc9f commit 84f288d

File tree

1 file changed

+29
-32
lines changed

1 file changed

+29
-32
lines changed

prettyprinter/src/Prettyprinter/Internal.hs

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -397,36 +397,33 @@ instance (Pretty a1, Pretty a2) => Pretty (a1,a2) where
397397
instance (Pretty a1, Pretty a2, Pretty a3) => Pretty (a1,a2,a3) where
398398
pretty (x1,x2,x3) = tupled [pretty x1, pretty x2, pretty x3]
399399

400-
-- -- | >>> pretty (123, "hello", False, ())
401-
-- -- (123, hello, False, ())
402-
-- instance (Pretty a1, Pretty a2, Pretty a3, Pretty a4) => Pretty (a1,a2,a3,a4) where
403-
-- pretty (x1,x2,x3,x4) = tupled [pretty x1, pretty x2, pretty x3, pretty x4]
404-
--
405-
-- -- | >>> pretty (123, "hello", False, (), 3.14)
406-
-- -- (123, hello, False, (), 3.14)
407-
-- instance (Pretty a1, Pretty a2, Pretty a3, Pretty a4, Pretty a5) => Pretty (a1,a2,a3,a4,a5) where
408-
-- pretty (x1,x2,x3,x4,x5) = tupled [pretty x1, pretty x2, pretty x3, pretty x4, pretty x5]
409-
--
410-
-- -- | >>> pretty (123, "hello", False, (), 3.14, Just 2.71)
411-
-- -- ( 123
412-
-- -- , hello
413-
-- -- , False
414-
-- -- , ()
415-
-- -- , 3.14
416-
-- -- , 2.71 )
417-
-- instance (Pretty a1, Pretty a2, Pretty a3, Pretty a4, Pretty a5, Pretty a6) => Pretty (a1,a2,a3,a4,a5,a6) where
418-
-- pretty (x1,x2,x3,x4,x5,x6) = tupled [pretty x1, pretty x2, pretty x3, pretty x4, pretty x5, pretty x6]
419-
--
420-
-- -- | >>> pretty (123, "hello", False, (), 3.14, Just 2.71, [1,2,3])
421-
-- -- ( 123
422-
-- -- , hello
423-
-- -- , False
424-
-- -- , ()
425-
-- -- , 3.14
426-
-- -- , 2.71
427-
-- -- , [1, 2, 3] )
428-
-- instance (Pretty a1, Pretty a2, Pretty a3, Pretty a4, Pretty a5, Pretty a6, Pretty a7) => Pretty (a1,a2,a3,a4,a5,a6,a7) where
429-
-- pretty (x1,x2,x3,x4,x5,x6,x7) = tupled [pretty x1, pretty x2, pretty x3, pretty x4, pretty x5, pretty x6, pretty x7]
400+
-- | >>> pretty (123, "hello", False, ())
401+
-- (123, hello, False, ())
402+
--
403+
-- @since FIXME
404+
instance (Pretty a1, Pretty a2, Pretty a3, Pretty a4) => Pretty (a1,a2,a3,a4) where
405+
pretty (x1,x2,x3,x4) = tupled [pretty x1, pretty x2, pretty x3, pretty x4]
406+
407+
-- | >>> pretty (123, "hello", False, (), 3.14)
408+
-- (123, hello, False, (), 3.14)
409+
--
410+
-- @since FIXME
411+
instance (Pretty a1, Pretty a2, Pretty a3, Pretty a4, Pretty a5) => Pretty (a1,a2,a3,a4,a5) where
412+
pretty (x1,x2,x3,x4,x5) = tupled [pretty x1, pretty x2, pretty x3, pretty x4, pretty x5]
413+
414+
-- | >>> pretty (123, "hello", False, (), 3.14, Just 2.71)
415+
-- (123, hello, False, (), 3.14, 2.71)
416+
--
417+
-- @since FIXME
418+
instance (Pretty a1, Pretty a2, Pretty a3, Pretty a4, Pretty a5, Pretty a6) => Pretty (a1,a2,a3,a4,a5,a6) where
419+
pretty (x1,x2,x3,x4,x5,x6) = tupled [pretty x1, pretty x2, pretty x3, pretty x4, pretty x5, pretty x6]
420+
421+
-- | >>> pretty (123, "hello", False, (), 3.14, Just 2.71, [1,2,3])
422+
-- (123, hello, False, (), 3.14, 2.71, [1, 2, 3])
423+
--
424+
-- @since FIXME
425+
instance (Pretty a1, Pretty a2, Pretty a3, Pretty a4, Pretty a5, Pretty a6, Pretty a7) => Pretty (a1,a2,a3,a4,a5,a6,a7) where
426+
pretty (x1,x2,x3,x4,x5,x6,x7) = tupled [pretty x1, pretty x2, pretty x3, pretty x4, pretty x5, pretty x6, pretty x7]
430427

431428
-- | Ignore 'Nothing's, print 'Just' contents.
432429
--
@@ -1810,8 +1807,8 @@ defaultLayoutOptions = LayoutOptions { layoutPageWidth = defaultPageWidth }
18101807
-- | This is the default layout algorithm, and it is used by 'show', 'putDoc'
18111808
-- and 'hPutDoc'.
18121809
--
1813-
-- @'layoutPretty'@ commits to rendering something in a certain way if the
1814-
-- remainder of the current line fits the layout constraints; in other words,
1810+
-- @'layoutPretty'@ commits to rendering something in a certain way if the
1811+
-- remainder of the current line fits the layout constraints; in other words,
18151812
-- it has up to one line of lookahead when rendering. Consider using the
18161813
-- smarter, but a bit less performant, @'layoutSmart'@ algorithm if the results
18171814
-- seem to run off to the right before having lots of line breaks.

0 commit comments

Comments
 (0)