{-# LANGUAGE RankNTypes, DeriveDataTypeable #-}

-- | Data structures that used to denote failure of accessing JSON values.
module Text.JSON.Failure
(
  NoSuchField(..)
, ExpectedObject(..)
, ExpectedBool(..)
, ExpectedNumber(..)
, ExpectedString(..)
, ExpectedArray(..)
, NoSuchFieldOrExpectedObject(..)
) where

import Data.Data

-- | An object field was attempted to access but the object has no such field.
data NoSuchField z =
  NoSuchField z
  deriving (Eq, Ord, Show, Data, Typeable)

-- | The JSON value was expected to be an object but it wasn't.
data ExpectedObject j =
  ExpectedObject j
  deriving (Eq, Ord, Show, Data, Typeable)

-- | The JSON value was expected to be an array but it wasn't.
data ExpectedArray j =
  ExpectedArray j
  deriving (Eq, Ord, Show, Data, Typeable)

-- | The JSON value was expected to be a boolean but it wasn't.
data ExpectedBool j =
  ExpectedBool j
  deriving (Eq, Ord, Show, Data, Typeable)

-- | The JSON value was expected to be a number but it wasn't.
data ExpectedNumber j =
  ExpectedNumber j
  deriving (Eq, Ord, Show, Data, Typeable)

-- | The JSON value was expected to be a string but it wasn't.
data ExpectedString j =
  ExpectedString j
  deriving (Eq, Ord, Show, Data, Typeable)

data NoSuchFieldOrExpectedObject z j =
  NoSuchFieldOrExpectedObject (forall x. (NoSuchField z -> x) -> (ExpectedObject j -> x) -> x)