Re: Union Types for Haskell!?

2000-11-27 Thread Marcin 'Qrczak' Kowalczyk
Mon, 27 Nov 2000 09:30:17 +0100, Bernd Holzmüller <[EMAIL PROTECTED]> pisze: > Consider you have a data structure (e.g. an abstract syntax tree) > consisting of nodes belonging to different data types. The difficulty > is to write a function that abstracts from the traversal of that > tree. I.e.

Re: Union Types for Haskell!?

2000-11-27 Thread Bernd Holzmüller
> Ashley Yakeley wrote: > A better question might be, having extended the type system (and indeed > the notion of 'type') in this way, how do I need to modify the concept of > 'principal type'? > ... > There are two different kinds of 'general' here. Informally, you want the > type most general

Re: Union Types for Haskell!?

2000-11-27 Thread Bernd Holzmüller
Hi Christian, Your suggestion is of course possible. However, it imposes an overhead which I would like to avoid. Consider you have a data structure (e.g. an abstract syntax tree) consisting of nodes belonging to different data types. The difficulty is to write a function that abstracts from the

Re: Union Types for Haskell!?

2000-11-24 Thread Johan Nordlander
Ashley Yakeley writes: > At 2000-11-24 02:02, Bernd =?iso-8859-2?Q?Holzm=FCller?= wrote: > >> When I got to know Haskell, I was expecting a construct for union types >> like: >> >> data B = ... >> data C = ... >> type A = B | C | D -- A accepts values of either B or C or D (cf. the >> "Either a

Re: Union Types for Haskell!?

2000-11-24 Thread Christian Lescher
Hi Bernd, > data B = ... > data C = ... > type A = B | C | D -- A accepts values of either B or C or D (cf. the > "Either a" type in the Prelude) What about the construction of a union type in Haskell like this?: data B = B1 | B2 data C = C1 | C2 | C3 data D = D1 | D2 data A = UB

Re: Union Types for Haskell!?

2000-11-24 Thread Pixel
Fergus Henderson <[EMAIL PROTECTED]> writes: [...] > (2) Allow pattern matching on values of particular types, > using `case'. [...] > If we allow (2), then some programming mistakes that previously > were type errors would instead become just inexhaustive pattern > matches for wh

Re: Union Types for Haskell!?

2000-11-24 Thread Ashley Yakeley
At 2000-11-24 03:14, Fergus Henderson wrote: >> Is there any reason for this restriction >> in the Haskell type system? Does this lead to losing the principal type >> property? > >If you allow (2) above, there may be serious problems for >principal types. For example, consider > > f x = ca

Re: Union Types for Haskell!?

2000-11-24 Thread Ashley Yakeley
At 2000-11-24 02:02, Bernd =?iso-8859-2?Q?Holzm=FCller?= wrote: >When I got to know Haskell, I was expecting a construct for union types >like: > > data B = ... > data C = ... > type A = B | C | D -- A accepts values of either B or C or D (cf. the >"Either a" type in the Prelude) > >but this i

Re: Union Types for Haskell!?

2000-11-24 Thread Fergus Henderson
On 24-Nov-2000, Bernd Holzmüller <[EMAIL PROTECTED]> wrote: > There is one thing I was really missing in all these projects: the > existence of union types (i.e. the union of value sets of two existing > data types) Mercury has a similar type system to Haskell. This question came up a lot during

Union Types for Haskell!?

2000-11-24 Thread Bernd Holzmüller
I am about to finish my PhD, where I used the Vienna Definition Language (VDL) to specify the semantics of some programming language constructs. In order to verify this semantics description using a type checker and by dynamic execution, I found and used Haskell as the language of choice to map th