@@ -1,6 +1,9 @@
1module Servant.QuickCheck.Internal.ErrorTypes where
1module Servant.QuickCheck.Internal.ErrorTypes where
3import Text.PrettyPrint
3import Text.PrettyPrint
5+import Data.String (IsString(fromString))
6+import GHC.Generics (Generic)
5data Request = Request
8data Request = Request
6 { requestBody :: String
9 { requestBody :: String
@@ -8,12 +11,12 @@ data Request = Request
8 , requestUrl :: String
11 , requestUrl :: String
9 } deriving (Eq, Show, Read, Generic)
12 } deriving (Eq, Show, Read, Generic)
11−prettyReq :: Doc
14+prettyReq :: Request -> Doc
12prettyReq r =
15prettyReq r =
13− text "Request:" $ nest 5 $
16+ text "Request:" $$ (nest 5 $
14− text "URL:" <+> text (nest 5 $ requestUrl r)
17+ text "URL:" <+> (nest 5 $ text $ requestUrl r)
15− $$ text "Headers:" <+>
18+ $$ text "Headers:" <+> (nest 5 $ hsep $ text <$> requestHeaders r)
16− $$ text "Body:" <+> text (nest 5 $ requestBody r)
19+ $$ text "Body:" <+> (nest 5 $ text $ requestBody r))
18instance IsString Request where
21instance IsString Request where
19 fromString url = Request "" [] url
22 fromString url = Request "" [] url
@@ -30,8 +33,8 @@ instance IsString Response where
30data Failure
33data Failure
31 = PredicateFailure String Request Response
34 = PredicateFailure String Request Response
32 | ServerEqualityFailure Request Response Response
35 | ServerEqualityFailure Request Response Response
33− deriving (Eq, Show, Read, Generic)
36+ deriving (Eq, Read, Generic)
35instance Show Failure where
38instance Show Failure where
36 show (PredicateFailure pred req resp)
39 show (PredicateFailure pred req resp)
37− = "Predicate failed for " <> pred <> "
40+ = "Predicate failed for " ++ pred