Hey there,

i was just thinking about types in Haskell and I asked myself,
Is there a mechanism, that allows me to define a new type out of an existing 
one with some restrictions?
So that the new type is a subset of the existing one.

Lets imagine I want a type for a point like:
type Point = (Int, Int)
But what, if I can predict that the X and Y values are in a range between 0 and 
100?
If someone defines a new point like:
                p :: Point
                p = (200, 400)
that is totally fine with the type definition above, but not correct in my 
context.

Is it possible, to put this information into the type? So that the compiler is 
able to recognize my mistake?

-- Matthias


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to