Closed vapourismo closed 5 years ago
Yes, I too think that everything should work exactly the same with barbies of kind (k -> Type) -> Type
(as is done, e.g. in parameterized-utils). I couldn't think of interesting examples of this at the time, but it is probably better not to introduce artificial restrictions, though, so I'll try to to lift this.
This is a use case I currently have:
type RowKind k = (k -> Type) -> Type
newtype Single :: k -> (k -> Type) -> Type
data Expression :: Type -> Type
class Row (row :: RowKind k)
data Statement :: RowKind Type -> Type where
TableOnly :: Text -> Statement row
Select
:: (TraversableB source, ConstraintsB source, AllB Row source)
=> (source (Single Expression) -> row Expression)
-> (source (Single Expression) -> Expression Bool)
-> source Statement
-> Statement row
The limitation here is that source :: RowKind Type -> Type
.
This is a very interesting example, thanks! So, b :: RowKind Type
is a type parameterized by a functor, i.e., a barbie, and source
is then a type parameterized by a barbie, which, as you observe, should also be a barbie
.
Gave it a quick try: lifting the restriction for FunctorB
, TraversableB
and ProductB
was easy enough. For ConstraintsB
, the generic derivation of AllB
breaks with an ugly compiler message, but I think this is because in AllB c b
, the kind of c
is now a function on b
, so hopefully fixable...
I think you've hit the same nasty error message that I encountered when I tried to refactor it to use PolyKinds
. Something about an unnamed type variable <tv>
not matching. I have been trying to figure out what it means ever since.
Yeah, that one :smile:
@vapourismo Still probably a bit rough around the edges, but if could you give #8 a try and report back, it'd be great.
I've tried a few base cases and they seem to work well. Haven't had the time to use it extensively, yet.
Released as v1.1.0.0
Barbie types are currently restricted to kind
(Type -> Type) -> Type
.As far as I can tell, all of the type class abstractions in this package would still work if one extends this restriction to a more poly-kinded one:
(k -> Type) -> Type
.Thoughts?