Currently, Vector has the inferred role type role Vector representational phantom nominal, which allows the following:
newtype Foo = Foo (Vector 10 Int)
exVec :: Vector 15 Int
exVec = fromJust $ fromListN @15 [1..15]
exFoo :: Foo
exFoo = coerce exVec -- no error
There is no error because n is phantom, so the coercion always works.
Instead, Vector should have type role Vector representational nominal nominal to disallow this coercion.
Currently,
Vectorhas the inferred roletype role Vector representational phantom nominal, which allows the following:There is no error because
nis phantom, so the coercion always works.Instead,
Vectorshould havetype role Vector representational nominal nominalto disallow this coercion.