<div dir="ltr">Oh, and here's the CoVec example:<br><br><div style="margin-left:40px"><span style="font-family:monospace,monospace">open import Agda.Builtin.Bool</span><br><span style="font-family:monospace,monospace">open import Agda.Builtin.Equality</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">record CoNat : Set where</span><br><span style="font-family:monospace,monospace">  coinductive</span><br><span style="font-family:monospace,monospace">  field</span><br><span style="font-family:monospace,monospace">    iszero : Bool</span><br><span style="font-family:monospace,monospace">    pred   : iszero ≡ false → CoNat</span><br><span style="font-family:monospace,monospace">open CoNat</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">zero : CoNat</span><br><span style="font-family:monospace,monospace">zero .iszero    = true</span><br><span style="font-family:monospace,monospace">zero .pred   ()</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">suc : CoNat → CoNat</span><br><span style="font-family:monospace,monospace">suc x .iszero      = false</span><br><span style="font-family:monospace,monospace">suc x .pred   refl = x</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">inf : CoNat</span><br><span style="font-family:monospace,monospace">inf .iszero      = false</span><br><span style="font-family:monospace,monospace">inf .pred   refl = inf</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">record CoVec (A : Set) (n : CoNat) : Set where</span><br><span style="font-family:monospace,monospace">  coinductive</span><br><span style="font-family:monospace,monospace">  field</span><br><span style="font-family:monospace,monospace">    hd :       n .iszero ≡ false  → A</span><br><span style="font-family:monospace,monospace">    tl : (pf : n .iszero ≡ false) → CoVec A (n .pred pf)</span><br><span style="font-family:monospace,monospace">open CoVec</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">[] : {A : Set} → CoVec A zero</span><br><span style="font-family:monospace,monospace">[] .hd ()</span><br><span style="font-family:monospace,monospace">[] .tl ()</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">_∷_ : {A : Set} {n : CoNat} → A → CoVec A n → CoVec A (suc n)</span><br><span style="font-family:monospace,monospace">(x ∷ xs) .hd refl = x</span><br><span style="font-family:monospace,monospace">(x ∷ xs) .tl refl = xs</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">repeat : {A : Set} → A → CoVec A inf</span><br><span style="font-family:monospace,monospace">repeat x .hd refl = x</span><br><span style="font-family:monospace,monospace">repeat x .tl refl = repeat x<br><br></span></div><br><div><span style="font-family:monospace,monospace"></span>-- Jesper<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 7, 2018 at 3:20 PM, Jesper Cockx <span dir="ltr"><<a href="mailto:Jesper@sikanda.be" target="_blank">Jesper@sikanda.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Probably you know you can already write this:<br></div><span style="font-family:monospace,monospace"><br></span><div style="margin-left:40px"><span style="font-family:monospace,monospace">open import Agda.Builtin.Nat</span><br><span style="font-family:monospace,monospace">open import Agda.Builtin.Equality</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">record Vec (A : Set) (n : Nat) : Set where</span><br><span style="font-family:monospace,monospace">  inductive</span><br><span style="font-family:monospace,monospace">  field</span><br><span style="font-family:monospace,monospace">    hd : ∀ {m} → n ≡ suc m → A</span><br><span style="font-family:monospace,monospace">    tl : ∀ {m} → n ≡ suc m → Vec A m</span><br><span style="font-family:monospace,monospace">open Vec</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">[] : ∀ {A} → Vec A 0</span><br><span style="font-family:monospace,monospace">[] .hd ()</span><br><span style="font-family:monospace,monospace">[] .tl ()</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">_∷_ : ∀ {A n} → A → Vec A n → Vec A (suc n)</span><br><span style="font-family:monospace,monospace">(x ∷ xs) .hd refl = x</span><br><span style="font-family:monospace,monospace">(x ∷ xs) .tl refl = xs<br><br></span></div>but I agree that having syntax for indexed records would be a nice thing to have. One problem with it is that your proposed syntax would break all existing code with records in it.<br><br></div>I was actually thinking recently of going in the opposite direction and making indexed datatypes behave more like records, so you could have projections and eta-laws when there's only a single possible constructor for the given indices (as would be the case for vectors). <br><br></div>-- Jesper<br><div><div><div><div><span style="font-family:monospace,monospace"></span><div style="margin-left:40px"><span style="font-family:monospace,monospace"></span></div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Mar 7, 2018 at 2:58 PM, Thorsten Altenkirch <span dir="ltr"><<a href="mailto:Thorsten.Altenkirch@nottingham.ac.uk" target="_blank">Thorsten.Altenkirch@<wbr>nottingham.ac.uk</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">



<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif">
<div>Using coinductive types as records I can write</div>
<div><br>
</div>
<div>
<div>    record Stream (A : Set) : Set where</div>
<div>        coinductive</div>
<div>        field</div>
<div>          hd : A</div>
<div>          tl : Stream A</div>
</div>
<div><br>
</div>
<div>and then use copatterns to define cons (after open Stream)</div>
<div><br>
</div>
<div>
<div>    _∷_ : {A : Set} → A → Stream A → Stream A</div>
<div>    hd (x ∷ xs) = x</div>
<div>    tl (x ∷ xs) = xs</div>
</div>
<div><br>
</div>
<div>Actually I wouldn't mind writing</div>
<div><br>
</div>
<div>
<div>    record Stream (A : Set) : Set where</div>
<div>      coinductive</div>
<div>      field</div>
<div>        hd : Stream A → A</div>
<div>        tl : Stream A → Stream A</div>
</div>
<div><br>
</div>
<div>as in inductive definitions we also write the codomain even though we know what it has to be. However, this is more interesting for families because we should be able to write</div>
<div><br>
</div>
<div>
<div>    record Vec (A : Set) : ℕ → Set where</div>
<div>      coinductive</div>
<div>      field</div>
<div>        hd : ∀{n} → Vec A (suc n) → A</div>
<div>        tl : ∀{n} → Vec A (suc n) → Vec A n</div>
</div>
<div><br>
</div>
<div>and we can derive [] and cons by copatterns:</div>
<div><br>
</div>
<div>
<div>    [] : Vec A zero</div>
<div>    [] ()</div>
<div><br>
</div>
<div>    _∷_ : {A : Set} → A → Vec A n → Vec A (suc n)</div>
<div>    hd (x ∷ xs) = x</div>
<div>    tl (x ∷ xs) = xs</div>
</div>
<div><br>
</div>
<div>here [] is defined as a trivial copattern (no destructor applies). Actually in this case the inductive and the coinductive vectors are isomorphic. A more interesting use case would be to define coinductive vectors indexed by conatural numbers. And I have
 others. :-)</div>
<div><br>
</div>
<div>Maybe this has been discussed already? I haven't been able to go to AIMs for a while.</div>
<div>Thorsten</div>
<div><br>
</div>
<br>
<pre>This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please contact the sender and delete the email and
attachment. 

Any views or opinions expressed by the author of this email do not
necessarily reflect the views of the University of Nottingham. Email
communications with the University of Nottingham may be monitored 
where permitted by law.



</pre></div>

<br></div></div>______________________________<wbr>_________________<br>
Agda mailing list<br>
<a href="mailto:Agda@lists.chalmers.se" target="_blank">Agda@lists.chalmers.se</a><br>
<a href="https://lists.chalmers.se/mailman/listinfo/agda" rel="noreferrer" target="_blank">https://lists.chalmers.se/mail<wbr>man/listinfo/agda</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>