[Haskell-beginners] Type declarations
Francesco Ariis
fa-ml at ariis.it
Sun Nov 26 21:41:35 UTC 2017
On Sun, Nov 26, 2017 at 10:21:39PM +0100, Patrik Iselind wrote:
> But if the type Point have a parameter, `data Point p = Coordinate p p`.
> Then i must be able to tell which `p` when i use Point in a type declaration
> right? Like `delta :: Point Double a -> Point Double b -> Double` would say
> that p is Double. How else am i supposed to specify p in type declaration?
If the type has a parameter, like
data Point a = Coordinates a a
it will specified *once* in the signature, like this:
f :: Point Double -> Point Double -> String
implementation looking something like
f (Coordinates x y) (Coordinates m q) = x + 7 -- etc. etc.
More information about the Beginners
mailing list