I am using a library linearand I am trying to create a way to reason about triangular matrices.
As a first step, I'm trying to create a way to figure out the size of the bottom triangular matrix. So, for example, it M22has a lower triangular matrix with 3 elements, so it will be displayed on V3.
Here is my attempt:
import Linear
type family LowerTriPacked v :: * -> *
type instance LowerTriPacked V0 = V0
type instance LowerTriPacked V1 = V1
type instance LowerTriPacked V2 = V3
But it does not introduce validation using:
Expecting one more argument to ‘V0’
The first argument of ‘LowerTriPacked’ should have kind ‘*’,
but ‘V0’ has kind ‘* -> *’
In the type ‘V0’
In the type instance declaration for ‘LowerTriPacked’
This is a type check:
type family LowerTriPacked2 v :: *
type instance LowerTriPacked2 (V0 a) = V0 a
type instance LowerTriPacked2 (V1 a) = V1 a
type instance LowerTriPacked2 (V2 a) = V3 a
But that’s not what I want, since now I can’t use
class (Traversable (LowerTriPacked2 v a)) => Triangular v a
Because it Traversablehas a view * -> *.
What happened to my syntax for the first attempt?
source
share