packages feed

morley-0.6.0: test/Test/Util/TypeSpec.hs

module Test.Util.TypeSpec
  ( ExactlyIs
  ) where

import Test.TypeSpec.Core
import Data.Singletons.Prelude.Eq (DefaultEq)
import Util.Type (If)
import Util.TypeLits (ErrorMessage (..))

-- | Like 'Is' but ensures that arguments match in kind.
data ExactlyIs (actual :: k) (expected :: k)
type instance EvalExpectation (ExactlyIs actual expected) =
  If (DefaultEq actual expected)
      (OK (ExactlyIs actual expected))
      (FAILED
        ('Text "Expected type: " ':<>: 'ShowType expected
          ':$$: 'Text "Actual type:   " ':<>: 'ShowType actual))

instance PrettyTypeSpec (ExactlyIs a b) where
  prettyTypeSpec _px = "Equal"