[Haskell-cafe] Mathematical functions with multiple arguments
Adam Bergmark
adam at bergmark.nl
Wed Mar 11 21:56:16 UTC 2015
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:
https://www.fpcomplete.com/user/konn/prove-your-haskell-for-great-safety/dependent-types-in-haskell
You'd end up with `plot :: (Vector n Double -> Double) -> Vector n (Double,
Double) -> IO ()' where `n' is the length of the vector.
HTH,
Adam
On Wed, Mar 11, 2015 at 10:45 PM, Sumit Sahrawat, Maths & Computing, IIT
(BHU) <sumit.sahrawat.apm13 at iitbhu.ac.in> wrote:
> Hi everybody,
>
> I have a function of type
>
> plot :: ([Double] -> Double) -- A function to plot
> -> [(Double, Double)] -- Range for all arguments
> -> IO ()
>
> I want to enforce the fact that ranges for all arguments should be
> provided.
> Is there a way to make the type system enforce it?
>
> --
> Regards
>
> Sumit Sahrawat
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150311/f67f004b/attachment.html>
More information about the Haskell-Cafe
mailing list