type-spec-0.2.0.0: Type Level Specification by Example

Safe HaskellNone
LanguageHaskell2010

Test.TypeSpec.Core

Contents

Description

Core of the TypeSpec abstractions. Import to add custom instances.

Synopsis

Core Data Type

data TypeSpec expectation where Source #

A type specification.

Constructors

Valid :: Try (EvalExpectation expectation) ~ expectation => TypeSpec expectation

Expect the given expectations to hold. If the compiler does not reject it - the expectation seem plausible.

Invalid :: DontTry (EvalExpectation expectation) => TypeSpec expectation

Expect the given expectations to **NOT** hold. If the compiler does not reject it - the expectation seem indeed implausible.

Instances

PrettyTypeSpec k t => Show (TypeSpec k t) Source # 

Methods

showsPrec :: Int -> TypeSpec k t -> ShowS #

show :: TypeSpec k t -> String #

showList :: [TypeSpec k t] -> ShowS #

Expectations

type family EvalExpectation (expectation :: k) :: Result k Source #

An open family of type level expectation evaluators, that return either () or an ErrorMessage.

Instances

type EvalExpectation Type (ShouldBeFalse t t1) Source # 
type EvalExpectation Type (ShouldBeTrue t t1) Source # 
type EvalExpectation Type (It expectation message expectation1) Source # 
type EvalExpectation Type (It expectation message expectation1) = (>>) Type (Either ErrorMessage) expectation (PrependToError expectation ((:$$:) (Text message) (Text " ")) (EvalExpectation expectation expectation1)) (OK ErrorMessage Type (It expectation message expectation1))
type EvalExpectation Type (ShouldNotBe expected actual expected1 actual1) Source # 
type EvalExpectation Type (ShouldNotBe expected actual expected1 actual1) = If (Either ErrorMessage Type) (EqExtra actual expected expected1 actual1) (FAILED ErrorMessage Type ((:$$:) ((:$$:) ((:$$:) (Text "Expected type: ") ((:<>:) (Text " ") (ShowType expected expected1))) (Text "to be different from: ")) ((:<>:) (Text " ") (ShowType actual actual1)))) (OK ErrorMessage Type (ShouldNotBe expected actual expected1 actual1))
type EvalExpectation Type (ShouldBe t t1 expected actual) Source # 
type EvalExpectation Type (ShouldBe t t1 expected actual) = If (Either ErrorMessage Type) (EqExtra t1 t expected actual) (OK ErrorMessage Type (ShouldBe t t1 expected actual)) (FAILED ErrorMessage Type ((:$$:) ((:<>:) (Text "Expected type: ") (ShowType t expected)) ((:<>:) (Text "Actual type: ") (ShowType t1 actual))))
type EvalExpectation Type (ButNot Type actual (ShouldBe t t1 expected actual1) other) Source # 
type EvalExpectation Type (ButNot Type actual (ShouldBe t t1 expected actual1) other) = If (Either ErrorMessage Type) (EqExtra t1 t expected actual1) (If (Either ErrorMessage Type) (EqExtra actual t expected other) (FAILED ErrorMessage Type ((:$$:) ((:$$:) ((:$$:) (Text "Expected type: ") ((:<>:) (Text " ") (ShowType t expected))) (Text "to be different from: ")) ((:<>:) (Text " ") (ShowType actual other)))) (OK ErrorMessage Type (ButNot Type actual (ShouldBe t t1 expected actual1) other))) (FAILED ErrorMessage Type ((:$$:) ((:<>:) (Text "Expected type: ") (ShowType t expected)) ((:<>:) (Text "Actual type: ") (ShowType t1 actual1))))
type EvalExpectation [k] ([] k) Source # 
type EvalExpectation [k] ([] k) = OK ErrorMessage [k] ([] k)
type EvalExpectation [a] ((:) a expectation rest) Source # 
type EvalExpectation [a] ((:) a expectation rest) = (<*>) (Either ErrorMessage) [a] [a] ((<$>) (Either ErrorMessage) a ((~>) [a] [a]) (Cons'' a) (EvalExpectation a expectation)) (EvalExpectation [a] rest)
type EvalExpectation * ((-/-) a1 a expectation expectations) Source # 
type EvalExpectation * ((-/-) a1 a expectation expectations) = (<*>) (Either ErrorMessage) a * ((<$>) (Either ErrorMessage) a1 ((~>) a *) (TyCon2 a1 a * ((-/-) a1 a)) (EvalExpectation a1 expectation)) (EvalExpectation a expectations)
type EvalExpectation (a1, a) ((,) a1 a a2 b) Source # 
type EvalExpectation (a1, a) ((,) a1 a a2 b) = (<*>) (Either ErrorMessage) a (a1, a) ((<$>) (Either ErrorMessage) a1 ((~>) a (a1, a)) (Pair'' a1 a) (EvalExpectation a1 a2)) (EvalExpectation a b)

Pretty Printing Support

class PrettyTypeSpec t where Source #

A class for pretty printing via the Show instance of TypeSpec.

Minimal complete definition

prettyTypeSpec

Methods

prettyTypeSpec :: proxy t -> Doc Source #

Instances

PrettyTypeSpec Type (ShouldBeFalse expectation a) Source # 

Methods

prettyTypeSpec :: proxy t -> Doc Source #

PrettyTypeSpec Type (ShouldBeTrue expectation a) Source # 

Methods

prettyTypeSpec :: proxy t -> Doc Source #

(KnownSymbol msg, PrettyTypeSpec expectation x) => PrettyTypeSpec Type (It expectation msg x) Source # 

Methods

prettyTypeSpec :: proxy t -> Doc Source #

(Showtype expected a, Showtype actual b) => PrettyTypeSpec Type (ShouldNotBe expected actual a b) Source # 

Methods

prettyTypeSpec :: proxy t -> Doc Source #

PrettyTypeSpec Type (ShouldBe expected actual a b) Source # 

Methods

prettyTypeSpec :: proxy t -> Doc Source #

((~) Type a (ShouldBe k k1 a0 a1), Showtype k a0, Showtype k1 a1, Showtype actual b) => PrettyTypeSpec Type (ButNot Type actual a b) Source # 

Methods

prettyTypeSpec :: proxy t -> Doc Source #

PrettyTypeSpec [k] ([] k) Source # 

Methods

prettyTypeSpec :: proxy t -> Doc Source #

(PrettyTypeSpec a expectation, PrettyTypeSpec [a] rest) => PrettyTypeSpec [a] ((:) a expectation rest) Source # 

Methods

prettyTypeSpec :: proxy t -> Doc Source #

(PrettyTypeSpec k expectation1, PrettyTypeSpec k1 expectation2) => PrettyTypeSpec * ((-/-) k k1 expectation1 expectation2) Source #

Pretty Printing Instance.

Methods

prettyTypeSpec :: proxy t -> Doc Source #

(PrettyTypeSpec k expectation1, PrettyTypeSpec k1 expectation2) => PrettyTypeSpec (k, k1) ((,) k k1 expectation1 expectation2) Source # 

Methods

prettyTypeSpec :: proxy t -> Doc Source #

prettyIndentation :: Int Source #

The default indention to use when nesting Documents.

nest' :: Doc -> Doc Source #

Nest using the default indention prettyIndentation.

sentence :: String -> Doc -> Doc Source #

Print a sentence with the second part hanging from the first. Generate: predicate: object