Currently Bare and Covered are plain types with kind *, so nothing prevents someone setting t to a type other than these two when using Wear. This will lead to Wear being stuck. Another approach is using DataKinds:
data Clothes = Bare | Covered
type family Wear (t :: Clothes) f a where
Wear Bare f a = a
Wear Covered f a = f a
This 1) introduces a breaking change and 2) forces users to use DataKinds.
This PR adds a catch-all case to Wear which raises a type error that looks like this:
> data MyTag
> undefined :: Wear MyTag Maybe String
<interactive>:8:1: error:
• `Wear` should only be used with `Bare` or `Covered`.
`MyTag` is not allowed in this context.
• When checking the inferred type
it :: (TypeError ...)
which is backwards compatible with current code that uses Wear
Currently
Bare
andCovered
are plain types with kind*
, so nothing prevents someone settingt
to a type other than these two when usingWear
. This will lead toWear
being stuck. Another approach is usingDataKinds
:This 1) introduces a breaking change and 2) forces users to use
DataKinds
.This PR adds a catch-all case to
Wear
which raises a type error that looks like this:which is backwards compatible with current code that uses
Wear