{-# LANGUAGE FlexibleInstances #-}
module Test.Hspec.Discover {-# WARNING
  "This module is used by @hspec-discover@.  It is not part of the public API and may change at any time."
  #-} (
  Spec
, hspec
, IsFormatter (..)
, hspecWithFormatter
, postProcessSpec
, describe
, module Prelude
) where

import           Prelude hiding (mapM)

import           Test.Hspec.Core.Spec
import           Test.Hspec.Core.Runner
import           Test.Hspec.Formatters

class IsFormatter a where
  toFormatter :: a -> IO Formatter

instance IsFormatter (IO Formatter) where
  toFormatter :: IO Formatter -> IO Formatter
toFormatter = IO Formatter -> IO Formatter
forall a. a -> a
id

instance IsFormatter Formatter where
  toFormatter :: Formatter -> IO Formatter
toFormatter = Formatter -> IO Formatter
forall (m :: * -> *) a. Monad m => a -> m a
return

hspecWithFormatter :: IsFormatter a => a -> Spec -> IO ()
hspecWithFormatter :: a -> Spec -> IO ()
hspecWithFormatter a
formatter Spec
spec = do
  Formatter
f <- a -> IO Formatter
forall a. IsFormatter a => a -> IO Formatter
toFormatter a
formatter
  Config -> Spec -> IO ()
hspecWith Config
defaultConfig {configFormatter :: Maybe Formatter
configFormatter = Formatter -> Maybe Formatter
forall a. a -> Maybe a
Just Formatter
f} Spec
spec

postProcessSpec :: FilePath -> Spec -> Spec
postProcessSpec :: FilePath -> Spec -> Spec
postProcessSpec FilePath
_ = Spec -> Spec
forall a. a -> a
id