Closed FranchuFranchu closed 4 months ago
Just a guess: what if you do Wrapper (a : Type) : Type
? I'm just looking at how List
is defined in https://github.com/Kindelia/Kind/blob/master/example/example.kind2 .
Kind doesn't do this type of unification, you need to manually indicate to the type checker that these things are the same (by clever use of let
s and annotations, type rewrites or the subst syntax), although I can never remember the right way to do it.
You could also break the nested pattern into two functions like this
Wrapper (a: Type) : Type
Wrapper.new <a> (v: a): Wrapper a
DoubleUnwrap <t: Type> (w: Wrapper (Wrapper t)) : t
DoubleUnwrap (Wrapper.new a) = Unwrap a
Unwrap <t: Type> (w: Wrapper t) : t
Unwrap (Wrapper.new a) = a
What @atennapel is not relevant in this case, but you probably don't want to declare your type with implicit parameter a
since it could lead to unexpected type inferences
The following code does not typecheck in kind2 0.2.79, and the current master branch neither.
It fails with