type-spec-0.4.0.0: Type Level Specification by Example

Safe HaskellNone
LanguageHaskell2010

Test.TypeSpecCrazy

Contents

Description

Funny operators that are mere type aliases for the constructs in TypeSpec

Synopsis

Crazy Type operators for It

type (--*) title expr = It title expr infixr 3 Source #

Alias for It, note that the number of ~s is alway a multiple of 3. This provides the impression of an underlined title followed by other expectations.

It allows to write the following type:

type ExpectationWithTitle =
  TypeSpec (

     "This is a title for some assertions:"
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     (2 + 2)  `Is`   4

   )

type (~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 Source #

Crazy Type operators for TypeSpec

type (###) title expr = Explain title expr infixr 1 Source #

Create a TypeSpec with an initial description or title followed by some expectations. Note that the number of #s is alway a multiple of 3.

It allows to rewrite the example above in a shorter way:

type ExpectationWithTitleShorter =

  "This is a title for some assertions:"
  ######################################

  (2 + 2)  `Is`   4

type (######) title expr = Explain title expr infixr 1 Source #

type (#########) title expr = Explain title expr infixr 1 Source #

type (############) title expr = Explain title expr infixr 1 Source #

type (###############) title expr = Explain title expr infixr 1 Source #

type (##################) title expr = Explain title expr infixr 1 Source #

type (#####################) title expr = Explain title expr infixr 1 Source #

type (########################) title expr = Explain title expr infixr 1 Source #

type (###########################) title expr = Explain title expr infixr 1 Source #

type (##############################) title expr = Explain title expr infixr 1 Source #

type (#################################) title expr = Explain title expr infixr 1 Source #

type (####################################) title expr = Explain title expr infixr 1 Source #

type (#######################################) title expr = Explain title expr infixr 1 Source #

type (##########################################) title expr = Explain title expr infixr 1 Source #

type (#############################################) title expr = Explain title expr infixr 1 Source #

Grouping Aliases

type (-*) expectation1 expectation2 = expectation1 -/- expectation2 infixr 4 Source #

Crazy operator alias for -/-.

Make a list of expectations. The precedence of this operator is even higher than that of -*-.

type (-*-) expectation1 expectation2 = expectation1 -/- expectation2 infixr 3 Source #

Crazy operator alias for -/- with higher precedence.

It allows to group expectations more beautiful than using type level lists.

specCrazyMoreNested ::

  "Title"
  ######

    "Top-level "
    ~~~~~~~~~~~~

         "Nested:"
         ~~~~~~~~~
         Int `Is` Int
                            -*-
         Int `Is` Int
                            -*-
         Int `Is` Int

                            -/-

    "Top-level "
    ~~~~~~~~~~~~

         "Nested:"
         ~~~~~~~~~
         Int `Is` Int
                            -*-
             "Nested:"
             ~~~~~~~~~
             Int `Is` Int
                            -*-
             Int `Is` Int

specCrazyMoreNested = Valid