    {-# OPTIONS_GHC -fno-warn-deprecations #-}
    {-# LANGUAGE LambdaCase #-}
    {-# LANGUAGE RecordWildCards #-}
    {-# LANGUAGE NamedFieldPuns #-}
    module Test.Hspec.Api.Format.V1.Internal (
      FailureReason(..)
    , module Test.Hspec.Api.Format.V1.Internal
    ) where

    import           Test.Hspec.Core.Util (stripAnsi)
    import           Test.Hspec.Core.Formatters.V1 (FailureReason(..))
    import qualified Test.Hspec.Api.Format.V2 as V2
    import           Test.Hspec.Api.Format.V2 hiding (Item(..), Result(..), FailureReason(..))

    data Item = Item {
      Item -> Maybe Location
    itemLocation :: Maybe Location
    , Item -> Seconds
    itemDuration :: Seconds
    , Item -> String
    itemInfo :: String
    , Item -> Result
    itemResult :: Result
    } deriving Int -> Item -> ShowS
    [Item] -> ShowS
    Item -> String
    (Int -> Item -> ShowS)
    -> (Item -> String) -> ([Item] -> ShowS) -> Show Item
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Item -> ShowS
    showsPrec :: Int -> Item -> ShowS
    $cshow :: Item -> String
    show :: Item -> String
    $cshowList :: [Item] -> ShowS
    showList :: [Item] -> ShowS
    Show

    data Result =
        Success
      | Pending (Maybe Location) (Maybe String)
      | Failure (Maybe Location) FailureReason
      deriving Int -> Result -> ShowS
    [Result] -> ShowS
    Result -> String
    (Int -> Result -> ShowS)
    -> (Result -> String) -> ([Result] -> ShowS) -> Show Result
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Result -> ShowS
    showsPrec :: Int -> Result -> ShowS
    $cshow :: Result -> String
    show :: Result -> String
    $cshowList :: [Result] -> ShowS
    showList :: [Result] -> ShowS
    Show

    liftItem :: Item -> V2.Item
    liftItem :: Item -> Item
    liftItem Item{String
    Maybe Location
    Seconds
    Result
    itemLocation :: Item -> Maybe Location
    itemDuration :: Item -> Seconds
    itemInfo :: Item -> String
    itemResult :: Item -> Result
    itemLocation :: Maybe Location
    itemDuration :: Seconds
    itemInfo :: String
    itemResult :: Result
    ..} = V2.Item {
      Maybe Location
    itemLocation :: Maybe Location
    itemLocation :: Maybe Location
    itemLocation
    , Seconds
    itemDuration :: Seconds
    itemDuration :: Seconds
    itemDuration
    , String
    itemInfo :: String
    itemInfo :: String
    itemInfo
    , itemResult :: Result
    itemResult = Result -> Result
    liftResult Result
    itemResult
    }

    unliftItem :: V2.Item -> Item
    unliftItem :: Item -> Item
    unliftItem V2.Item{String
    Maybe Location
    Seconds
    Result
    itemLocation :: Item -> Maybe Location
    itemDuration :: Item -> Seconds
    itemInfo :: Item -> String
    itemResult :: Item -> Result
    itemLocation :: Maybe Location
    itemDuration :: Seconds
    itemInfo :: String
    itemResult :: Result
    ..} = Item {
      Maybe Location
    itemLocation :: Maybe Location
    itemLocation :: Maybe Location
    itemLocation
    , Seconds
    itemDuration :: Seconds
    itemDuration :: Seconds
    itemDuration
    , String
    itemInfo :: String
    itemInfo :: String
    itemInfo
    , itemResult :: Result
    itemResult = Result -> Result
    unliftResult Result
    itemResult
    }

    liftResult :: Result -> V2.Result
    liftResult :: Result -> Result
    liftResult = \ case
      Result
    Success -> Result
    V2.Success
      Pending Maybe Location
    loc Maybe String
    reason -> Maybe Location -> Maybe String -> Result
    V2.Pending Maybe Location
    loc Maybe String
    reason
      Failure Maybe Location
    loc FailureReason
    reason -> Maybe Location -> FailureReason -> Result
    V2.Failure Maybe Location
    loc (FailureReason -> FailureReason
    liftFailureReson FailureReason
    reason)

    unliftResult :: V2.Result -> Result
    unliftResult :: Result -> Result
    unliftResult = \ case
      Result
    V2.Success -> Result
    Success
      V2.Pending Maybe Location
    loc Maybe String
    reason -> Maybe Location -> Maybe String -> Result
    Pending Maybe Location
    loc Maybe String
    reason
      V2.Failure Maybe Location
    loc FailureReason
    reason -> Maybe Location -> FailureReason -> Result
    Failure Maybe Location
    loc (FailureReason -> FailureReason
    unliftFailureReason FailureReason
    reason)

    liftFailureReson :: FailureReason -> V2.FailureReason
    liftFailureReson :: FailureReason -> FailureReason
    liftFailureReson = \ case
      FailureReason
    NoReason -> FailureReason
    V2.NoReason
      Reason String
    reason -> String -> FailureReason
    V2.Reason String
    reason
      ExpectedButGot Maybe String
    preface String
    expected String
    actual -> Maybe String -> String -> String -> FailureReason
    V2.ExpectedButGot Maybe String
    preface String
    expected String
    actual
      Error Maybe String
    info SomeException
    e -> Maybe String -> SomeException -> FailureReason
    V2.Error Maybe String
    info SomeException
    e

    unliftFailureReason :: V2.FailureReason -> FailureReason
    unliftFailureReason :: FailureReason -> FailureReason
    unliftFailureReason = \ case
      FailureReason
    V2.NoReason -> FailureReason
    NoReason
      V2.Reason String
    reason -> String -> FailureReason
    Reason String
    reason
      V2.ColorizedReason String
    reason -> String -> FailureReason
    Reason (ShowS
    stripAnsi String
    reason)
      V2.ExpectedButGot Maybe String
    preface String
    expected String
    actual -> Maybe String -> String -> String -> FailureReason
    ExpectedButGot Maybe String
    preface String
    expected String
    actual
      V2.Error Maybe String
    info SomeException
    e -> Maybe String -> SomeException -> FailureReason
    Error Maybe String
    info SomeException
    e