[Prev][Next][Index][Thread]

intersection values and union types?



Hi,

I'm looking for references on practical work where
- the intersection type operator (/\) is allowed for simple values 
  (eg: 0 /\ [])
- non-homogeneous lists (eg: [ 1 ; "foo" ] has type List(Int | String))

The best i've found are
- "Programming With Intersection Types, Union Types, and Polymorphism" B.Pierce [1]
- "Design of the Programming Language Forsythe" J.Reynolds [2]

but i'm no good with theory and find it really hard to parse through the
various papers (including ITRS'00 [3]). So if i'd be kind if someone could
give some non too theoretical pointers :)


Why those questions? Well I've been playing with a language (no theory at all,
just practical usage) based on this:
- union operator (|) allows extensible variants
- intersection operator (/\) allows ad'hoc overloading, extensible records and
    interface inheritance
- full structural equivalence

and I just found out the various existing terminology for describing this :-/


Some examples:

(syntax mainly based on caml with
 A !! B means "the type of A is B"
 A !< B means "the type of A is a subtype of B"
 A !> B means "the type of A is a supertype of B")

1 !! 1
1 !< Int           (where Int = 0|1|...)
"foo" !! "foo"
"foo" !< String    (where String = ""|"a"|"b"|"aa"|... (set of all strings))
[ 1 ; "foo" ] !! [ 1 ; "foo" ]
[ 1 ; "foo" ] !< List(1 | "foo")
[ 1 ; "foo" ] !< List(Int | String)

map (fun x -> x + (1 /\ "bar")) [ 1 ; "foo" ]
  gives [ 2 ; "foobar" ]
  using + !! Int->Int->Int /\ String->String->String


for more: http://merd.sf.net/types.png, http://merd.sf.net

Thanks!

[1] http://citeseer.nj.nec.com/14271.html 
[2] http://citeseer.nj.nec.com/reynolds96design.html
[3] http://www.cee.hw.ac.uk/~jbw/itrs/itrs00
--
Pixel