<div dir="ltr">You&#39;d need GHC extensions to pull that off, Greg, but it could be done. Something like<div><br></div><div>data Vect (size :: Nat) (a :: *) where</div><div>  Cons :: a -&gt; Vect n a -&gt; Vect (Succ n) a</div>

<div>  Nil :: Vect Zero a</div><div><br></div><div>data NatUpTo (n :: Nat) where</div><div>  Here :: NatUpTo n -- &quot;Here&quot; means 0</div><div>  There :: NatUpTo n -&gt; NatUpTo (S n) -- &quot;There x&quot; means 1 + x</div>

<div><br></div><div>vectIndex :: Vect (S n) a -&gt; NatUpTo n -&gt; a<br></div><div>vectIndex (Cons x _) Here = a</div><div>vectIndex (Cons _ xs) (There i) = vectIndex xs i</div><div><br></div><div>class (Enum a) =&gt; EnumSize (size :: Nat) a where</div>

<div>  enumerateAll :: Vect size a</div><div>  -- law: (enumerateAll `asTypeOf` [x]) `vectIndex` unsafeIntToNatUpTo (fromEnum x)</div><div><br></div><div>It gets tedious, though, dealing with all of that safety. LiquidHaskell is perhaps a more viable option for such a thing. It would be nice to have standard libraries written with LiquidHaskell so that we have a more rigorously proven code base.</div>

</div><div class="gmail_extra"><br clear="all"><div>-- Dan Burton</div>
<br><br><div class="gmail_quote">On Wed, Sep 11, 2013 at 10:57 AM, Greg Fitzgerald <span dir="ltr">&lt;<a href="mailto:garious@gmail.com" target="_blank">garious@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

I&#39;d prefer something more like:<br>
<br>
    mux :: Enum b =&gt; [a] -&gt; b -&gt; a<br>
    mux xs x = xs !! fromEnum x<br>
<br>
so then &#39;bool&#39; could be implemented as:<br>
<div class="im"><br>
    bool :: a -&gt; a -&gt; Bool -&gt; a<br>
</div>    bool f t = mux [f, t]<br>
<br>
but &#39;mux&#39; needs a stronger type signature.  The size of the enum is<br>
known at compile-time.  Is there any way to constrain the input list<br>
to be the same size?<br>
<br>
Thanks,<br>
Greg<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
On Wed, Sep 11, 2013 at 2:18 AM, Simon Hengel &lt;<a href="mailto:sol@typeful.net">sol@typeful.net</a>&gt; wrote:<br>
&gt; On Tue, Sep 10, 2013 at 11:02:19PM +0100, Oliver Charles wrote:<br>
&gt;&gt; I would like to propose that the following is added to Data.Bool in base:<br>
&gt;&gt;<br>
&gt;&gt; bool :: a -&gt; a -&gt; Bool -&gt; a<br>
&gt;&gt; bool f _ False = f<br>
&gt;&gt; bool _ t True  = t<br>
&gt;<br>
&gt; +1<br>
&gt; _______________________________________________<br>
&gt; Libraries mailing list<br>
&gt; <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
</div></div></blockquote></div><br></div>