module FP.Pretty.Instances where

import FP.Prelude
import FP.Pretty.Pretty
import FP.Pretty.Deriving

instance Pretty Doc where 
  pretty = id

instance Pretty ๐”น where pretty = ppCon โˆ˜ ๐•ค โˆ˜ show
instance Pretty ๐•€ where pretty = ppLit โˆ˜ ๐•ค โˆ˜ show
instance Pretty โ„ค where pretty = ppLit โˆ˜ ๐•ค โˆ˜ show
instance Pretty โ„• where pretty = ppLit โˆ˜ ๐•ค โˆ˜ show
instance Pretty โ„•แต€ where 
  pretty NInfinity = ppLit "โˆž"
  pretty (NFinite n) = pretty n
instance Pretty โ„‚ where pretty = ppLit โˆ˜ ๐•ค โˆ˜ show
instance Pretty ๐•Š where pretty = ppLit โˆ˜ ๐•ค โˆ˜ show
instance Pretty ๐”ป  where pretty = ppLit โˆ˜ ๐•ค โˆ˜ show
instance Pretty () where pretty = ppCon โˆ˜ ๐•ค โˆ˜ show

instance (Pretty a, Pretty b) โ‡’ Pretty (a, b) where
  pretty (a, b) = ppCollection "(" ")" "," [pretty a, pretty b]
instance (Pretty a, Pretty b, Pretty c) โ‡’ Pretty (a, b, c) where
  pretty (a, b, c) = ppCollection "(" ")" "," [pretty a, pretty b, pretty c]

instance (Pretty a) โ‡’ Pretty (Stream a) where pretty xs = ppApp (ppText "stream") [pretty $ list xs]
instance (Pretty a) โ‡’ Pretty [a] where pretty = ppCollection "[" "]" "," โˆ˜ map pretty
instance (Pretty a) โ‡’ Pretty (๐’ซ a) where pretty = ppCollection "{" "}"  "," โˆ˜ map pretty โˆ˜ list
instance (Pretty a,Ord a) โ‡’ Pretty (๐’ซแต‡ a) where pretty = pretty โˆ˜ concretizeSet
instance (Pretty k,Pretty v) โ‡’ Pretty (k โ‡ฐ v) where pretty = ppRecord "โ†ฆ" โˆ˜ map (mapPair pretty pretty) โˆ˜ list
instance (Pretty k,Pretty v,Ord k,Monoid v) โ‡’ Pretty (k โ‡ฐโ™ญโงบ v) where pretty = pretty โˆ˜ concretizeDictAppend
instance (Pretty k,Pretty v,Ord k,JoinLattice v) โ‡’ Pretty (k โ‡ฐโ™ญโŠ” v) where pretty = pretty โˆ˜ concretizeDictJoin

instance (Pretty a) โ‡’ Pretty (AddBot a) where
  pretty Bot = ppCon "โŠฅ"
  pretty (AddBot x) = pretty x

instance (Pretty a) โ‡’ Pretty (AddTop a) where
  pretty Top = ppCon "โŠค"
  pretty (AddTop x) = pretty x

instance (Functorial Pretty f) โ‡’ Pretty (Fixed f) where
  pretty (Fixed f) =
    with (functorial โˆท W (Pretty (f (Fixed f)))) $
    pretty f

makePrettySum ''Maybe
makePrettySum ''Either

makePrettyUnion ''ID