module Text.Show.Text.Data.Version (
showbVersionPrec
, showbVersionConcrete
) where
import Data.List (intersperse)
#if !(MIN_VERSION_base(4,8,0))
import Data.Monoid (mconcat)
#endif
import Data.Text.Lazy.Builder (Builder, fromString)
import Data.Version (Version(..))
import Text.Show.Text.Classes (showb, showbPrec)
import Text.Show.Text.Data.Char ()
import Text.Show.Text.Data.Integral ()
import Text.Show.Text.Data.List ()
import Text.Show.Text.TH.Internal (deriveShowPragmas, defaultInlineShowbPrec)
import Text.Show.Text.Utils ((<>), s)
showbVersionPrec :: Int -> Version -> Builder
showbVersionPrec = showbPrec
showbVersionConcrete :: Version -> Builder
showbVersionConcrete (Version branch tags)
= mconcat (intersperse (s '.') $ map showb branch) <>
mconcat (map ((s '-' <>) . fromString) tags)
$(deriveShowPragmas defaultInlineShowbPrec ''Version)