module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.MIME (MIME (..)) where

import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), Value (String), withText)
import "base" Control.Applicative (pure)
import "base" Data.Function ((.))
import "base" Data.Functor ((<$>))
import "base" Text.Show (Show)
import "text" Data.Text (Text)

import Network.API.Telegram.Bot.Property.Accessible (Accessible (access))

newtype MIME = MIME Text deriving Show

instance Accessible Text MIME where
        access f (MIME txt) = (\txt' -> MIME txt') <$> f txt

instance FromJSON MIME where
        parseJSON = withText "MIME" (pure . MIME)

instance ToJSON MIME where
        toJSON (MIME txt) = String txt