packages feed

telega-0.3.0: Network/API/Telegram/Bot/Field/Caption.hs

module Network.API.Telegram.Bot.Field.Caption (Caption (..)) where

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

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

newtype Caption = Caption Text

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

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

instance ToJSON Caption where
	toJSON (Caption txt) = toJSON txt