<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Fri, Dec 6, 2013 at 12:00 PM, Sergei Meshveliani <span dir="ltr"><<a href="mailto:mechvel@botik.ru" target="_blank">mechvel@botik.ru</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Please, how to write this via `case' ?<br>
<br>
This is the conversion of a Boolean predicate to the decidable one:<br>
<br>
----------------------------------------------------------------------<br>
open import Data.Unit using (⊤)<br>
open import Data.Bool as Bool using (Bool; true; false; T)<br>
<br>
boolP→Dec : ∀ {α} {A : Set α} → (P : A → Bool) → let P' : A → Set<br>
P' = T ∘ P<br>
in Decidable P'<br>
boolP→Dec P x with P x<br>
... | true = yes ⊤.tt<br>
... | false = no λ()<br>
----------------------------------------------------------------------<br>
<br>
How to rewrite this via `case', so that it is type-checked ?<br>
(in development Agda of November 2013).<br></blockquote><div><br></div><div>boolP→Dec : ∀ {α} {A : Set α} → (P : A → Bool) → Decidable (T ∘ P)</div><div>boolP→Dec P x =</div><div> case P x return Dec ∘ T of λ</div><div>
{ true → yes _</div><div> ; false → no λ()</div><div> } </div><div><br></div><div>You need to use case_return_of_ since it's a dependent pattern match (the type of the branches are different).</div><div><br></div>
<div>/ Ulf</div></div></div></div>