{-# OPTIONS_GHC -fno-warn-orphans #-}

module Text.Blaze.Instances
  (
  ) where

import ClassyPrelude
import Text.Blaze
import qualified Text.Blaze.Renderer.Text as Text

import Text.Read (Read(..))

import Data.Hashable (Hashable(..))
import Data.Aeson (ToJSON(..), FromJSON(..))
import qualified Data.Aeson as Aeson


instance Eq Markup where
  (==) = (==) `on` Text.renderMarkup

instance Ord Markup where
  compare = comparing Text.renderMarkup

instance Read Markup where
  readPrec = preEscapedLazyText <$> readPrec

instance Show Markup where
  showsPrec prec = showsPrec prec . Text.renderMarkup

instance Hashable Markup where
  hashWithSalt s = hashWithSalt s . Text.renderMarkup

instance ToJSON Markup where
  toJSON = Aeson.String . toStrict . Text.renderMarkup

instance FromJSON Markup where
  parseJSON = Aeson.withText "Html" $ return . preEscapedText
