module TextShow.Data.UnorderedContainers (
showbHashMapPrecWith2
, showbHashSetPrec
, showbHashSetPrecWith
) where
import qualified Data.HashMap.Lazy as HM (toList)
import Data.HashMap.Lazy (HashMap)
import qualified Data.HashSet as HS (toList)
import Data.HashSet (HashSet)
import TextShow (TextShow(showbPrec), TextShow1(..), TextShow2(..),
Builder, showbPrec1)
import TextShow.Data.Tuple (showb2TupleWith2)
import TextShow.Utils (showbUnaryList, showbUnaryListWith)
#include "inline.h"
showbHashMapPrecWith2 :: (k -> Builder) -> (v -> Builder)
-> Int -> HashMap k v -> Builder
showbHashMapPrecWith2 sp1 sp2 p =
showbUnaryListWith (showb2TupleWith2 sp1 sp2) p . HM.toList
showbHashSetPrec :: TextShow a => Int -> HashSet a -> Builder
showbHashSetPrec p = showbUnaryList p . HS.toList
showbHashSetPrecWith :: (a -> Builder) -> Int -> HashSet a -> Builder
showbHashSetPrecWith sp p = showbUnaryListWith sp p . HS.toList
instance (TextShow k, TextShow v) => TextShow (HashMap k v) where
showbPrec = showbPrec1
INLINE_INST_FUN(showbPrec)
instance TextShow k => TextShow1 (HashMap k) where
showbPrecWith = showbPrecWith2 showbPrec
INLINE_INST_FUN(showbPrecWith)
instance TextShow2 HashMap where
showbPrecWith2 sp1 sp2 = showbHashMapPrecWith2 (sp1 0) (sp2 0)
INLINE_INST_FUN(showbPrecWith2)
instance TextShow a => TextShow (HashSet a) where
showbPrec = showbHashSetPrec
INLINE_INST_FUN(showbPrec)
instance TextShow1 HashSet where
showbPrecWith sp = showbHashSetPrecWith $ sp 0
INLINE_INST_FUN(showbPrecWith)