Monday, April 18, 2011

[byntxjsl] Structured type parameters

This would be annoying to have to type over and over again:

foo :: a -> Bar a b c d e f g h Int;

Or (MyClass a b c d e f g h) => a -> b ...

We need a way of organizing and naming collections of types and type variables for, at this point, a purely hypothetical problem.  I think the answer is to be able to organize many variables into records, though there are probably difficult details lurking.

type BarVec {v:::Mystruct} x = Bar v.a v.b v.c v.d v.e v.f v.g.foo v.g.bar x
typestruct Mystruct = { scalar a,b,c,d,e,f ; FooBar g}
typestruct FooBar = { scalar foo,bar }

foo :: v.a -> (BarVec v Int)

Template Haskell can probably do this.

1 comment :

Tom Schrijvers said...

Try using type families to emulate your type structures.