<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; 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></body>
</html>