<div dir="ltr">It's done. fixed-vector provides many implementations for Vec. The one I was using (Primitive) requires primitive constraint on data types. I shifted to Unboxed ones, and now it's working.<div><br></div><div>This means that I am able to use toList with Vec v (Double, Double), which was previously complaining of missing constraints.<br><div><br></div><div>Also, I'll slowly convert the whole thing. I wanted to just see if it works initially.</div><div>Thanks, once again.</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 March 2015 at 04:58, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">I'd urge you to *try* to maintain that safety throughout, but you can try something like this if necessary (I'm not at my computer, so I can't test it):</p>
<p dir="ltr">{-#LANGUAGE FlexibleContexts, FlexibleInstances #-}<br>
instance Foldable (SL Z) where<br>
  foldr _ n Nil = n</p>
<p dir="ltr">instance Foldable (SL n) => Foldable (SL (S n)) where<br>
  foldr c n (Cons x xs) = c x (foldr c n xs)</p>
<p dir="ltr">In fact, I would expect whatever package you're looking at to offer this. Then you can just use Data.Foldable.toList.</p><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Mar 11, 2015 7:16 PM, "Sumit Sahrawat, Maths & Computing, IIT (BHU)" <<a href="mailto:sumit.sahrawat.apm13@iitbhu.ac.in" target="_blank">sumit.sahrawat.apm13@iitbhu.ac.in</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The fixed-vector package uses a similar technique. The only trouble I'm having is with converting Vec v (Double, Double) to [(Double, Double)] for further use. I don't want to change all the code, but only the part where the user provides me with arguments.<div><br></div><div>I'll keep looking into it. Thanks for the help.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 March 2015 at 04:44, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">There are a lot of ways to do this sort of thing, and which one you choose will depend on exactly what you're trying to do. For example, you can write something vaguely like</p>
<p dir="ltr">data Nat = Z | S Nat<br>
data SL (n :: Nat) a where<br>
  Nil :: SL Z<br>
  Cons :: a -> SL n a -> SL (S n) a</p>
<p dir="ltr">plot :: forall (n::Nat) . (SL n Double -> Double) -><br>
                                        SL n (Double, Double) -> IO ()</p>
<div class="gmail_quote"><div><div>On Mar 11, 2015 5:45 PM, "Sumit Sahrawat, Maths & Computing, IIT (BHU)" <<a href="mailto:sumit.sahrawat.apm13@iitbhu.ac.in" target="_blank">sumit.sahrawat.apm13@iitbhu.ac.in</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div>Hi everybody,</div><div><br></div>I have a function of type<div><br></div><div><font face="monospace, monospace">    plot :: ([Double] -> Double)    -- A function to plot</font></div><div><font face="monospace, monospace">         -> [(Double, Double)]      -- Range for all arguments</font></div><div><font face="monospace, monospace">         -> IO ()</font><br clear="all"><div><br></div><div>I want to enforce the fact that ranges for all arguments should be provided.</div><div>Is there a way to make the type system enforce it?</div><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Regards</div><div dir="ltr"><div><br></div><div>Sumit Sahrawat</div></div></div></div></div></div></div>
</div></div>
<br></div></div><span>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></span></blockquote></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Regards</div><div dir="ltr"><div><br></div><div>Sumit Sahrawat</div></div></div></div></div></div></div>
</div>
</blockquote></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Regards</div><div dir="ltr"><div><br></div><div>Sumit Sahrawat</div></div></div></div></div></div></div>
</div>