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

module Data.CaseInsensitive.Instances () where

import Prelude

import Data.CaseInsensitive (CI)
import qualified Data.CaseInsensitive as CI

import Servant.API.ContentTypes

import Data.Aeson


instance MimeRender PlainText a => MimeRender PlainText (CI a) where
  mimeRender p = mimeRender p . CI.original

instance ToJSON a => ToJSON (CI a) where
  toJSON = toJSON . CI.original

instance (FromJSON a, CI.FoldCase a) => FromJSON (CI a) where
  parseJSON = fmap CI.mk . parseJSON