module Text.Show.Text.Data.Containers (
showbIntMapPrec
, showbIntSetPrec
, showbMapPrec
, showbSequencePrec
, showbViewLPrec
, showbViewRPrec
, showbSetPrec
, showbTreePrec
) where
import qualified Data.Foldable as F
import qualified Data.IntMap as IM
import Data.IntMap (IntMap)
import qualified Data.IntSet as IS
import Data.IntSet (IntSet)
import qualified Data.Map as M
import Data.Map (Map)
import Data.Sequence (Seq, ViewL, ViewR)
import qualified Data.Set as Set
import Data.Set (Set)
import Data.Tree (Tree)
import Prelude hiding (Show)
import Text.Show.Text (Builder, Show(showbPrec), Show1(showbPrec1))
import Text.Show.Text.Data.Integral ()
import Text.Show.Text.Data.List ()
import Text.Show.Text.Data.Tuple ()
import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowbPrec)
import Text.Show.Text.Utils (showbUnaryList)
#include "inline.h"
showbIntMapPrec :: Show v => Int -> IntMap v -> Builder
showbIntMapPrec p = showbUnaryList p . IM.toList
showbIntSetPrec :: Int -> IntSet -> Builder
showbIntSetPrec p = showbUnaryList p . IS.toList
showbMapPrec :: (Show k, Show v) => Int -> Map k v -> Builder
showbMapPrec p = showbUnaryList p . M.toList
showbSequencePrec :: Show a => Int -> Seq a -> Builder
showbSequencePrec p = showbUnaryList p . F.toList
showbViewLPrec :: Show a => Int -> ViewL a -> Builder
showbViewLPrec = showbPrec
showbViewRPrec :: Show a => Int -> ViewR a -> Builder
showbViewRPrec = showbPrec
showbSetPrec :: Show a => Int -> Set a -> Builder
showbSetPrec p = showbUnaryList p . Set.toList
showbTreePrec :: Show a => Int -> Tree a -> Builder
showbTreePrec = showbPrec
instance Show v => Show (IntMap v) where
showbPrec = showbIntMapPrec
INLINE_INST_FUN(showbPrec)
instance Show IntSet where
showbPrec = showbIntSetPrec
INLINE_INST_FUN(showbPrec)
instance (Show k, Show v) => Show (Map k v) where
showbPrec = showbMapPrec
INLINE_INST_FUN(showbPrec)
instance Show a => Show (Seq a) where
showbPrec = showbSequencePrec
INLINE_INST_FUN(showbPrec)
instance Show a => Show (Set a) where
showbPrec = showbSetPrec
INLINE_INST_FUN(showbPrec)
$(deriveShowPragmas defaultInlineShowbPrec ''ViewL)
$(deriveShowPragmas defaultInlineShowbPrec ''ViewR)
$(deriveShowPragmas defaultInlineShowbPrec ''Tree)
instance Show1 IntMap where
showbPrec1 = showbIntMapPrec
INLINE_INST_FUN(showbPrec1)
instance Show k => Show1 (Map k) where
showbPrec1 = showbMapPrec
INLINE_INST_FUN(showbPrec1)
instance Show1 Seq where
showbPrec1 = showbSequencePrec
INLINE_INST_FUN(showbPrec1)
instance Show1 ViewL where
showbPrec1 = showbViewLPrec
INLINE_INST_FUN(showbPrec1)
instance Show1 ViewR where
showbPrec1 = showbViewRPrec
INLINE_INST_FUN(showbPrec1)
instance Show1 Set where
showbPrec1 = showbSetPrec
INLINE_INST_FUN(showbPrec1)
instance Show1 Tree where
showbPrec1 = showbTreePrec
INLINE_INST_FUN(showbPrec1)