{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module TextShow.Data.Version (showbVersion) where
import Data.List (intersperse)
import Data.Text.Lazy.Builder (Builder, fromString, singleton)
import Data.Version (Version(..))
import Prelude ()
import Prelude.Compat
import TextShow.Classes (TextShow(..))
import TextShow.Data.Char ()
import TextShow.Data.Integral ()
import TextShow.Data.List ()
import TextShow.TH.Internal (deriveTextShow)
showbVersion :: Version -> Builder
showbVersion (Version branch tags)
= mconcat (intersperse (singleton '.') $ map showb branch) <>
mconcat (map ((singleton '-' <>) . fromString) tags)
{-# INLINE showbVersion #-}
$(deriveTextShow ''Version)