Re: Type Pattern-Matching for Existential Types

2001-02-01 Thread Tom Pledger
Lennart Augustsson writes: [...] > Slightly more interesting might be > data Foo = forall a . Foo a (a -> Int) > > Now you can at least apply the function to the value after pattern > matching. You don't have to carry any types around, because the > type system ensures that you don't misu

Re: Type Pattern-Matching for Existential Types

2001-01-31 Thread C.Reinke
> > > data Any = forall a. Any a > > > > > > get :: Any -> Maybe Char > > > get (Any (c::Char)) = Just c -- bad > > > get _ = Nothing .. > It can also be questioned from a software engineering standpoint. Much > of the purpose with existential types is to provide information hiding; > that is, th

Re: Type Pattern-Matching for Existential Types

2001-01-31 Thread Fergus Henderson
On 30-Jan-2001, Johan Nordlander <[EMAIL PROTECTED]> wrote: > It can also be questioned from a software engineering standpoint. Much > of the purpose with existential types is to provide information hiding; > that is, the user of an existentially quantified type is not supposed to > know its conc

Re: Type Pattern-Matching for Existential Types

2001-01-31 Thread Johan Nordlander
Ashley Yakeley wrote: > > At 2001-01-30 23:11, Johan Nordlander wrote: > > >However, this whole idea gets forfeited if it's possible to look behind > >the abstraction barrier by pattern-matching on the representation. > > Isn't this information-hiding more appropriately achieved by hiding the >

Re: Type Pattern-Matching for Existential Types

2001-01-30 Thread Ashley Yakeley
At 2001-01-30 23:11, Johan Nordlander wrote: >However, this whole idea gets forfeited if it's possible to look behind >the abstraction barrier by pattern-matching on the representation. Isn't this information-hiding more appropriately achieved by hiding the constructor? -- data IntOrChar = Mk

Re: Type Pattern-Matching for Existential Types

2001-01-30 Thread Johan Nordlander
Lennart Augustsson wrote: > > Ashley Yakeley wrote: > > > data Any = forall a. Any a > > > > get :: Any -> Maybe Char > > get (Any (c::Char)) = Just c -- bad > > get _ = Nothing > > -- > > > > ...but as it stands, this is not legal Haskell, according to Hugs: > > > > ERROR "test.hs" (line 4): Ty

Re: Type Pattern-Matching for Existential Types

2001-01-30 Thread Fergus Henderson
On 31-Jan-2001, Lennart Augustsson <[EMAIL PROTECTED]> wrote: > Ashley Yakeley wrote: > > > data Any = forall a. Any a > > > > get :: Any -> Maybe Char > > get (Any (c::Char)) = Just c -- bad > > get _ = Nothing > > -- > > > > ...but as it stands, this is not legal Haskell, according to Hugs: > >

Re: Type Pattern-Matching for Existential Types

2001-01-30 Thread Lennart Augustsson
Ashley Yakeley wrote: > At 2001-01-30 22:16, Lennart Augustsson wrote: > > >It has large and horrible implications. To do dynamic type tests you need > >to carry around the types at runtime. This is not something that Haskell > >does (at least you don't have to). > > Hmm. In this: > > -- > data

Re: Type Pattern-Matching for Existential Types

2001-01-30 Thread Ashley Yakeley
At 2001-01-30 22:16, Lennart Augustsson wrote: >It has large and horrible implications. To do dynamic type tests you need >to carry around the types at runtime. This is not something that Haskell >does (at least you don't have to). Hmm. In this: -- data Any = forall a. Any a a1 = Any 3 a2 =

Re: Type Pattern-Matching for Existential Types

2001-01-30 Thread Lennart Augustsson
Ashley Yakeley wrote: > data Any = forall a. Any a > > get :: Any -> Maybe Char > get (Any (c::Char)) = Just c -- bad > get _ = Nothing > -- > > ...but as it stands, this is not legal Haskell, according to Hugs: > > ERROR "test.hs" (line 4): Type error in application > *** Expression : Any c

Type Pattern-Matching for Existential Types

2001-01-30 Thread Ashley Yakeley
At 2001-01-30 19:52, Fergus Henderson wrote: >On 30-Jan-2001, Ashley Yakeley <[EMAIL PROTECTED]> wrote: >> At 2001-01-30 02:37, Fergus Henderson wrote: >> >> >class BaseClass s where >> >downcast_to_derived :: s -> Maybe Derived >> >> Exactly what I was trying to avoid, since now every base