    module Test.Hspec.SmallCheck.Types where

    import           Prelude ()
    import           Test.Hspec.SmallCheck.Compat

    import           Data.List
    import           Test.Hspec.Core.Spec (Location(..))

    data Result = Failure (Maybe Location) Reason
      deriving (Result -> Result -> Bool
    (Result -> Result -> Bool)
    -> (Result -> Result -> Bool) -> Eq Result
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Result -> Result -> Bool
    == :: Result -> Result -> Bool
    $c/= :: Result -> Result -> Bool
    /= :: Result -> Result -> Bool
    Eq, 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, ReadPrec [Result]
    ReadPrec Result
    Int -> ReadS Result
    ReadS [Result]
    (Int -> ReadS Result)
    -> ReadS [Result]
    -> ReadPrec Result
    -> ReadPrec [Result]
    -> Read Result
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Result
    readsPrec :: Int -> ReadS Result
    $creadList :: ReadS [Result]
    readList :: ReadS [Result]
    $creadPrec :: ReadPrec Result
    readPrec :: ReadPrec Result
    $creadListPrec :: ReadPrec [Result]
    readListPrec :: ReadPrec [Result]
    Read)

    data Reason =
        Reason String
      | ExpectedActual String String String
      deriving (Reason -> Reason -> Bool
    (Reason -> Reason -> Bool)
    -> (Reason -> Reason -> Bool) -> Eq Reason
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Reason -> Reason -> Bool
    == :: Reason -> Reason -> Bool
    $c/= :: Reason -> Reason -> Bool
    /= :: Reason -> Reason -> Bool
    Eq, Int -> Reason -> ShowS
    [Reason] -> ShowS
    Reason -> String
    (Int -> Reason -> ShowS)
    -> (Reason -> String) -> ([Reason] -> ShowS) -> Show Reason
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Reason -> ShowS
    showsPrec :: Int -> Reason -> ShowS
    $cshow :: Reason -> String
    show :: Reason -> String
    $cshowList :: [Reason] -> ShowS
    showList :: [Reason] -> ShowS
    Show, ReadPrec [Reason]
    ReadPrec Reason
    Int -> ReadS Reason
    ReadS [Reason]
    (Int -> ReadS Reason)
    -> ReadS [Reason]
    -> ReadPrec Reason
    -> ReadPrec [Reason]
    -> Read Reason
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Reason
    readsPrec :: Int -> ReadS Reason
    $creadList :: ReadS [Reason]
    readList :: ReadS [Reason]
    $creadPrec :: ReadPrec Reason
    readPrec :: ReadPrec Reason
    $creadListPrec :: ReadPrec [Reason]
    readListPrec :: ReadPrec [Reason]
    Read)

    parseResult :: String -> (String, Maybe Result)
    parseResult :: String -> (String, Maybe Result)
    parseResult String
    xs =  case [(String
    x, Result -> Maybe Result
    forall a. a -> Maybe a
    Just Result
    y) | (String
    x, Just Result
    y) <- [String] -> [Maybe Result] -> [(String, Maybe Result)]
    forall a b. [a] -> [b] -> [(a, b)]
    zip (String -> [String]
    forall a. [a] -> [[a]]
    inits String
    xs) ((String -> Maybe Result) -> [String] -> [Maybe Result]
    forall a b. (a -> b) -> [a] -> [b]
    map String -> Maybe Result
    forall a. Read a => String -> Maybe a
    readMaybe ([String] -> [Maybe Result]) -> [String] -> [Maybe Result]
    forall a b. (a -> b) -> a -> b
    $ String -> [String]
    forall a. [a] -> [[a]]
    tails String
    xs)] of
      (String, Maybe Result)
    r : [(String, Maybe Result)]
    _ -> (String, Maybe Result)
    r
      [] -> (String
    xs, Maybe Result
    forall a. Maybe a
    Nothing)

    concatPrefix :: String -> String -> Maybe String
    concatPrefix :: String -> String -> Maybe String
    concatPrefix String
    a String
    b = case (String -> Bool) -> [String] -> [String]
    forall a. (a -> Bool) -> [a] -> [a]
    filter (Bool -> Bool
    not (Bool -> Bool) -> (String -> Bool) -> String -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Bool
    forall a. [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null) ([String] -> [String]) -> [String] -> [String]
    forall a b. (a -> b) -> a -> b
    $ [String
    a, String
    b] of
      [] -> Maybe String
    forall a. Maybe a
    Nothing
      [String]
    xs -> String -> Maybe String
    forall a. a -> Maybe a
    Just (String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate String
    "\n" [String]
    xs)