-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Type Level Specification by Example -- -- Please see README.md @package type-spec @version 0.4.0.0 -- | Useful abstractions for type level programming using. This -- reimplements parts of the singletons library, which is just too heavy -- of a dependency to carry around, when only three small types are used -- of it. module Test.TypeSpec.Internal.Apply -- | Bind to actions. type family (>>=) (ma :: monad a) (f :: a ~> ((monad b) :: Type)) :: monad b -- | Execute one action and then the next, ignore the result of the first. type (>>) ma mb = ma >>= Const' mb -- | Execute an action that returns a function than map function over the -- result of the next action. type family (f :: m (a ~> b)) <*> (ma :: m a) :: m b data Pair'' :: a ~> b ~> (a, b) data Pair' :: a -> b ~> (a, b) data Cons'' :: a ~> [a] ~> [a] data Cons' :: a -> [a] ~> [a] data TyCon1 :: (a -> b) -> a ~> b data TyCon2 :: (a -> b -> c) -> a ~> b ~> c data (<$>$$) :: (a ~> b) ~> m a ~> m b data (<$>$) :: (a ~> b) -> m a ~> m b type family (f :: (a ~> b)) <$> (ma :: m a) :: m b data Flip' :: (a ~> b ~> c) ~> b ~> a ~> c data Flip :: (a ~> b ~> c) -> b ~> a ~> c data Flip_ :: (a ~> b ~> c) -> b -> a ~> c type family Flip__ (f :: (a ~> b ~> c)) (y :: b) (x :: a) :: c data Compose'' :: (b ~> c) ~> (a ~> b) ~> (a ~> c) data Compose' :: (b ~> c) -> (a ~> b) ~> (a ~> c) data Compose :: (b ~> c) -> (a ~> b) -> (a ~> c) type family Compose_ (f :: b ~> c) (g :: a ~> b) (x :: a) :: c type family Const (a :: t) (b :: t') :: t data Const' :: a -> (b ~> a) data Const'' :: a ~> (b ~> a) data TyFun :: Type -> Type -> Type type a ~> b = TyFun a b -> Type infixr 0 ~> type family Apply (f :: a ~> b) (x :: a) :: b -- | Useful abstractions for type level programming using Either. module Test.TypeSpec.Internal.Either -- | Return the left type of a promoted Either type family FromLeft (e :: Either a b) :: a -- | Type Equality module Test.TypeSpec.Internal.Equality -- | Operator 'Data.Equality.(==)' expects both arguments to have the same -- kind. type family EqExtra (a :: ak) (b :: bk) :: Bool -- | A result type used in constraints inside TypeSpec to chain -- computations that may fail with a TypeError. module Test.TypeSpec.Internal.Result -- | When a type level expectation is tested, it might be that compound -- expectations fail. In order to have a small, precise error message, -- the type level assertion results are made to have kind Result. type Result = Either ErrorMessage -- | A nice alias for Right type FAILED = 'Left -- | A nice alias for Left type OK = 'Right -- | Return the result or fail with a TypeError type family Try (e :: Result k) :: k -- | A constraint that is satisfied if the parameter is Left. Fails -- with a TypeError otherwise. type family DontTry (e :: Result r) :: Constraint -- | In case of Left ErrorMessage prepend a message -- to the message, if the parameter was Right x just -- return Right x. type family PrependToError (message :: ErrorMessage) (result :: Result a) :: Result a -- | Core of the TypeSpec abstractions. Import to add custom instances. module Test.TypeSpec.Core -- | A type specification. data TypeSpec expectation -- | Expect the given expectations to hold. If the compiler does not reject -- it - the expectation seem plausible. [Valid] :: Try (EvalExpectation expectation) ~ expectation => TypeSpec expectation -- | Expect the given expectations to **NOT** hold. If the compiler does -- not reject it - the expectation seem indeed implausible. [Invalid] :: DontTry (EvalExpectation expectation) => TypeSpec expectation -- | An open family of type level expectation evaluators, that return -- either () or an ErrorMessage. type family EvalExpectation (expectation :: k) :: Result k -- | A class for pretty printing via the Show instance of -- TypeSpec. class PrettyTypeSpec (t :: k) prettyTypeSpec :: PrettyTypeSpec t => proxy t -> Doc -- | The default indention to use when nesting Documents. prettyIndentation :: Int instance forall k (t :: k). Test.TypeSpec.Core.PrettyTypeSpec t => GHC.Show.Show (Test.TypeSpec.Core.TypeSpec t) instance forall k1 k2 (expectation1 :: k2) (expectation2 :: k1). (Test.TypeSpec.Core.PrettyTypeSpec expectation1, Test.TypeSpec.Core.PrettyTypeSpec expectation2) => Test.TypeSpec.Core.PrettyTypeSpec '(expectation1, expectation2) instance Test.TypeSpec.Core.PrettyTypeSpec '[] instance forall a (expectation :: a) (rest :: [a]). (Test.TypeSpec.Core.PrettyTypeSpec expectation, Test.TypeSpec.Core.PrettyTypeSpec rest) => Test.TypeSpec.Core.PrettyTypeSpec (expectation : rest) -- | Composed Expectations. module Test.TypeSpec.Group -- | Combine two expectations. -- -- Make a collection of expectations: -- --
--   (2 + 2)  `Is`     4
--                           -/-
--   (4 + 4)  `Is`     8
--                           -/-
--   'True    `IsNot` 'False
--   
data expectation1 -/- expectation2 infixr 1 -/- instance forall k1 k2 (expectation1 :: k2) (expectation2 :: k1). (Test.TypeSpec.Core.PrettyTypeSpec expectation1, Test.TypeSpec.Core.PrettyTypeSpec expectation2) => Test.TypeSpec.Core.PrettyTypeSpec (expectation1 Test.TypeSpec.Group.-/- expectation2) -- | Labels for expectations. module Test.TypeSpec.Label -- | Add a type level string as label or longer descripton around -- expectations. This is analog to the it function in the -- hspec package. data It :: Symbol -> expectation -> Type instance forall expectation (msg :: GHC.Types.Symbol) (x :: expectation). (GHC.TypeLits.KnownSymbol msg, Test.TypeSpec.Core.PrettyTypeSpec x) => Test.TypeSpec.Core.PrettyTypeSpec (Test.TypeSpec.Label.It msg x) -- | Type level assertions on type equality. module Test.TypeSpec.ShouldBe -- | State that two types or type constructs are boiled down to the same -- type. data ShouldBe :: actual -> expected -> Type -- | State that two types or type constructs are NOT the same type. data ShouldNotBe :: actual -> expected -> Type -- | State that a type is equal to the type level True. data ShouldBeTrue :: expectation -> Type -- | State that a type is equal to the type level False. data ShouldBeFalse :: expectation -> Type -- | State that one type is different to two other types. This must always -- be used right next to a ShouldBe pair, otherwise this will not -- work. data ButNot :: shouldBe -> shouldntBe -> Type instance forall expected actual (a :: actual) (b :: expected). Test.TypeSpec.Core.PrettyTypeSpec (Test.TypeSpec.ShouldBe.ShouldNotBe a b) instance forall expected actual (a :: actual) (b :: expected). Test.TypeSpec.Core.PrettyTypeSpec (Test.TypeSpec.ShouldBe.ShouldBe a b) instance forall shouldntBe expected actual a (a0 :: actual) (a1 :: expected) (b :: shouldntBe). (a Data.Type.Equality.~ Test.TypeSpec.ShouldBe.ShouldBe a0 a1) => Test.TypeSpec.Core.PrettyTypeSpec (Test.TypeSpec.ShouldBe.ButNot a b) instance forall expectation (a :: expectation). Test.TypeSpec.Core.PrettyTypeSpec (Test.TypeSpec.ShouldBe.ShouldBeFalse a) instance forall expectation (a :: expectation). Test.TypeSpec.Core.PrettyTypeSpec (Test.TypeSpec.ShouldBe.ShouldBeTrue a) -- | A tiny EDSL to write type-level-unit tests. -- -- A simple example: -- --
--   specHelloWorld :: Expect (Int `Isn't` Bool)
--   specHelloWorld = Valid
--   
-- -- We can also expect a bit more using lists and tuples: -- --
--   specGrouped
--     :: Expect '[ Int  `Isn't` Bool
--                , Int  `Is`    Int
--                , Bool `Is`    Bool  `ButNot`  String
--                ]
--   specGrouped = Valid
--   
-- -- The expectations are executed by the compiler when solving the -- constraints of TypeSpecs constructors. -- -- A TypeSpec also has a Show instance, which can be used -- in real unit tests to print the expectations. -- -- This module contains mainly re-exports of. -- -- module Test.TypeSpec type Expect = TypeSpec type Explain does this = TypeSpec (It does this) type Is = ShouldBe type IsTheSameAs = ShouldBe type TheseAreEqual = ShouldBe type IsNot = ShouldNotBe type Isn't = ShouldNotBe type IsNotTheSameAs = ShouldNotBe type IsDifferentFrom = ShouldNotBe type TheseAreNotEqual = ShouldNotBe type IsTrue = ShouldBeTrue type And = ShouldBeTrue type Therefore = ShouldBeTrue type That = ShouldBeTrue type IsFalse = ShouldBeFalse type Not = ShouldBeTrue type They message expectations = It message expectations type Describe = It type Context = It type It's = It -- | Funny operators that are mere type aliases for the constructs in -- TypeSpec module Test.TypeSpecCrazy -- | 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 --* type (~~~) title expr = It title expr infixr 3 ~~~ type (~~~~~~) title expr = It title expr infixr 3 ~~~~~~ type (~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~ type (~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) title expr = It title expr infixr 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- | 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 ### type (######) title expr = Explain title expr infixr 1 ###### type (#########) title expr = Explain title expr infixr 1 ######### type (############) title expr = Explain title expr infixr 1 ############ type (###############) title expr = Explain title expr infixr 1 ############### type (##################) title expr = Explain title expr infixr 1 ################## type (#####################) title expr = Explain title expr infixr 1 ##################### type (########################) title expr = Explain title expr infixr 1 ######################## type (###########################) title expr = Explain title expr infixr 1 ########################### type (##############################) title expr = Explain title expr infixr 1 ############################## type (#################################) title expr = Explain title expr infixr 1 ################################# type (####################################) title expr = Explain title expr infixr 1 #################################### type (#######################################) title expr = Explain title expr infixr 1 ####################################### type (##########################################) title expr = Explain title expr infixr 1 ########################################## type (#############################################) title expr = Explain title expr infixr 1 ############################################# type (################################################) title expr = Explain title expr infixr 1 ################################################ type (###################################################) title expr = Explain title expr infixr 1 ################################################### type (######################################################) title expr = Explain title expr infixr 1 ###################################################### type (#########################################################) title expr = Explain title expr infixr 1 ######################################################### type (############################################################) title expr = Explain title expr infixr 1 ############################################################ type (###############################################################) title expr = Explain title expr infixr 1 ############################################################### type (##################################################################) title expr = Explain title expr infixr 1 ################################################################## type (#####################################################################) title expr = Explain title expr infixr 1 ##################################################################### type (########################################################################) title expr = Explain title expr infixr 1 ######################################################################## -- | 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 4 -* -- | 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
--   
type expectation1 -*- expectation2 = expectation1 -/- expectation2 infixr 3 -*-