module TextShow.Data.Containers () where
import qualified Data.Foldable as F
import Data.Graph (SCC)
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 TextShow (TextShow(..), TextShow1(..), TextShow2(..), showbPrec1)
import TextShow.Data.Integral ()
import TextShow.TH (deriveTextShow, deriveTextShow1)
import TextShow.Utils (showbUnaryListWith)
instance TextShow v => TextShow (IntMap v) where
showbPrec = showbPrec1
instance TextShow1 IntMap where
liftShowbPrec sp _ p =
showbUnaryListWith (liftShowbList2 showbPrec undefined
(const (sp 0)) undefined) p . IM.toList
instance TextShow IntSet where
showbPrec p = showbUnaryListWith showbList p . IS.toList
instance (TextShow k, TextShow v) => TextShow (Map k v) where
showbPrec = showbPrec1
instance TextShow k => TextShow1 (Map k) where
liftShowbPrec = liftShowbPrec2 showbPrec showbList
instance TextShow2 Map where
liftShowbPrec2 sp1 _ sp2 _ p =
showbUnaryListWith (liftShowbList2 (const (sp1 0)) undefined
(const (sp2 0)) undefined) p . M.toList
instance TextShow a => TextShow (Seq a) where
showbPrec = showbPrec1
instance TextShow1 Seq where
liftShowbPrec _ sl p = showbUnaryListWith sl p . F.toList
$(deriveTextShow ''ViewL)
$(deriveTextShow1 ''ViewL)
$(deriveTextShow ''ViewR)
$(deriveTextShow1 ''ViewR)
instance TextShow a => TextShow (Set a) where
showbPrec = showbPrec1
instance TextShow1 Set where
liftShowbPrec _ sl p = showbUnaryListWith sl p . Set.toList
$(deriveTextShow ''SCC)
$(deriveTextShow1 ''SCC)
$(deriveTextShow ''Tree)
$(deriveTextShow1 ''Tree)