<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 11, 2015 at 5:56 PM, Adam Bergmark <span dir="ltr"><<a href="mailto:adam@bergmark.nl" target="_blank">adam@bergmark.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">If I understand you correctly you seem to want dependent types, this article uses the same example you need, promoting the length of a vector/list to the type level:Â <a href="https://www.fpcomplete.com/user/konn/prove-your-haskell-for-great-safety/dependent-types-in-haskell" target="_blank">https://www.fpcomplete.com/user/konn/prove-your-haskell-for-great-safety/dependent-types-in-haskell</a><div><br></div><div>You'd end up with `plot :: (Vector n Double -> Double) -> Vector n (Double, Double) -> IO ()' where `n' is the length of the vector.</div></div></blockquote></div><br>It seems like tuples are more straightforward:<br><br>class Plot x where<br>Â plot :: (x -> Double)<br>Â Â Â -> x -- ^ lower bound<br>Â Â Â -> x -- ^ upper bound<br>Â Â Â -> IO ()<br><br>instance Plot Double where<br>Â plot = plot2d<br><br>instance Plot (Double,Double) where<br>Â plot = plot3d<br><br>And then that lets you do something like:<br><br>instance Plot (Double, Shingle Double) where<br>Â plot = plot2d_faceted<br><br>-- | <a href="https://stat.ethz.ch/R-manual/R-devel/library/lattice/html/shingles.html">https://stat.ethz.ch/R-manual/R-devel/library/lattice/html/shingles.html</a><br>data Shingle a = Shingle [(a,a)] a<br><br><br>Regards,<br>Adam Vogt<br></div></div>