[Haskell-cafe] Types in bounds

2008-09-01 Thread Brettschneider, Matthias
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 =

Re: [Haskell-cafe] Types in bounds

2008-09-01 Thread Johannes Waldmann
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? 1. this only works with dependent types, which Haskell does not have - by design (type inference/checking would be undecidable). It works

Re: [Haskell-cafe] Types in bounds

2008-09-01 Thread Johannes Waldmann
type Point = (Int, Int) 2. using type (instead of data) is generally a bad idea. and in this case, using data Point ... would allow to define a smart constructor that can at least check at run-time whether the bounds are met. - J.W. signature.asc Description: OpenPGP digital signature

Re: [Haskell-cafe] Types in bounds

2008-09-01 Thread Marc Weber
On Mon, Sep 01, 2008 at 11:45:12AM +0200, Brettschneider, Matthias wrote: 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