Does this code compile?  I&#39;d expect that<br><br> 
 instance Bool (Js JsBool) (Js r) where<br><br>violates the fundep, since it applies for *all* values of r, not just to one.<br><br>   - Conal<br><br><div class="gmail_quote">On Tue, Jun 30, 2009 at 8:53 AM, Sebastiaan Visser <span dir="ltr">&lt;<a href="mailto:sfvisser@cs.uu.nl">sfvisser@cs.uu.nl</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">On Jun 30, 2009, at 5:24 PM, Conal Elliott wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Sebastiaan,<br>
<br>
I like your extensions of generalized booleans to other common Haskell types!<br>
<br>
I also prefer using type families to fundeps.  In this case I didn&#39;t because of some awkwardness with vector operations, but I&#39;m going to try again.<br>
<br>
I&#39;m confused about your particular fundep choice.  For instance,<br>
<br>
class Bool f r | f -&gt; r where<br>
 bool  :: r -&gt; r -&gt; f -&gt; r<br>
 false :: f<br>
 true  :: f<br>
<br>
Do you *really* mean that the boolean type f determines the value type r?<br>
</blockquote>
<br></div>
Yes, that is really what I mean. This can be used to enforce that the return value of elimination can be restricted by the boolean type. This is especially useful when using GADTs to encode your domain language.<br>
<br>
For example, take this simple JavaScript language:<br>
  data Js a where<br>
    Prim :: String -&gt; Js a                -- Primitive embedding.<br>
    App :: Js (a -&gt; b) -&gt; Js a -&gt; Js b    -- Function application.<br>
<br>
  data JsBool<br>
<br>
Now the functional dependencies can be used to enforce that eliminating booleans in the Js domain always returns a value in the Js domain:<br>
  instance Bool (Js JsBool) (Js r) where<br>
    bool f t c = Prim &quot;(function ifthenelse (f, t, c) c ? t : f)&quot; `App` f `App` t `App` c<br>
    true  = Prim &quot;true&quot;<br>
    false = Prim &quot;false&quot;<br>
Getting rid of this fundep and using type families will probably be a lot more intuitive.<br>
<br>
Any suggestions on how to enforce elimination to be able to go from `Js JsBool -&gt; Js r&#39; using other techniques?<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Regards,   - Conal<br>
<br>
...<br>
</blockquote>
<br>
--<br><font color="#888888">
Sebastiaan Visser<br>
<br>
<br>
<br>
</font></blockquote></div><br><br>[]