[ah, this majordomo doesn't send you copies of your own emails. That
confused me for a while...]
On Thu, Sep 02, 2004 at 04:05:34PM +0100, Thorsten Altenkirch wrote:
> Jules Bean wrote:
> >Been playing and, well... it's amazing stuff. Here are the problems
> >I've run into:
> >
> >* as constructor declarations,
> >nil:List X and (----------! are inequivalent, strangely (?)
> > !nil:List X)
> >
>
> nil : List X is not (syntactically) a constructor declaration. The 2nd
> version
> is correct.
...yet zero:Nat and suc:Nat->Nat are syntactically ok. So the
difference in the form without the proof-rule syntax is that the proof
rule syntax can see the implicit type parameter X?
[snip my example]
> Just declare the domain types in the order they are applied.
Ah, is this because the domain types might be dependent on each other,
and for partial application of constructors to work, the earlier
parameters may not be dependent on later ones?
> I.e. nil is a good example: if you write nil X above instead of nil you
> always have
> to supply the type when using nil.
Ok, thanks.
> >That's the obvious things. I also can't get a non-trivial instance of
> >the 'oh So true' trick to work, but that might be operator error, or
> >it might just been you haven't written enough of the proof search code
> >yet.
>
> What is "a non-trivial instance of the 'oh So true' trick"?
The terminology is Conor's; he explained the trick to me once, and it
is also mentioned in 'A View from the Left' I believe. Define the
type So b, for boolean b, to have a single constructor oh : So
true. This ensures that the type So E is only inhabitable if E
evaluates to a true expression. You can use this to impose invariants
on types. I tried to use it to make an implicit form of the type 'list
containing the particular element x'. The definition elaborates fine
but I can't build programs using it; I can send the example but it is
lengthy, I should try to minimise it first.
I have a simpler problem also:
------------------------------------------------------------------------------
( n : Nat !
data (---------! where zero : Nat ; !-------------!
! Nat : * ) ! suc n : Nat )
------------------------------------------------------------------------------
( n : Nat ; X : * ! ( x : X ; xs : vec n X !
data !------------------! where (--------------! ; !-----------------------!
! vec n X : * ) ! nil : ! ! cons x xs : !
! vec zero X ) ! vec (suc n) X )
------------------------------------------------------------------------------
( n : Nat ; X : * ; v : vec n X !
let !---------------------------------! ; length v => n
! length v : Nat )
------------------------------------------------------------------------------
Why won't length type check? the 'n' is on a yellow background.
Cheers,
Jules