how to exploit existential types

1999-02-20 Thread S.D.Mechveliani
To my example-question on using existential type Michael Hobbs [EMAIL PROTECTED] writes [...] But my real point in replying to this message is to see if you actually need a multi-type list. Do you really *need* to have separate types for DMeat, DVine, etc.? For example, instead of having:

Re: Haskell 2 -- Dependent types?

1999-02-20 Thread Lennart Augustsson
Nick Kallen [EMAIL PROTECTED] wrote: apply f (p:ps) = apply (f p) ps apply f [] = f I wanted to express the type as something like: apply :: (a - a - ... - a) [a] - a No, that's not what you want. :-) You want apply :: (a - a - ... - b) [a] - b I think the distinction is important

RE: Haskell 2 -- Dependent types?

1999-02-20 Thread Nick Kallen
I wanted to express the type as something like: apply :: (a - a - ... - a) [a] - a No, that's not what you want. :-) You want apply :: (a - a - ... - b) [a] - b I think the distinction is important (see below). F a * = member (map (F a) [0..]) // member [a] a - Bool I mave no

RE: Haskell 2 -- Dependent types?

1999-02-20 Thread Nick Kallen
If your language supports optional dynamic type checking, as it should, then expressing functions like apply shouldn't be too hard. Here's a dynamic apply in a pseudo Clean 2.0 syntax: apply :: Dynamic [a] - a apply (f :: a - b) (arg:args) = apply (dynamic (f arg) :: b) args apply (f :: a) []

Re: Do Existential Types make Algebraic Types obsolete? (was Re: how to exploit existential types)

1999-02-20 Thread Michael Hobbs
Fergus Henderson wrote: What would happen if `write' was called with an MVar variable and an Error variable? Would the `exitWith' function get called, or would the `putMVar' function get called? Haskell doesn't normally let you define clauses for the same function in different modules.