Hi -
I'm wondering if there is any possiblility of getting intersection types
into Haskell. For example, at the moment there is no (proper) typing for:
f g x y = (g x, g y)
Ideally, I'd like to be able to write:
f:: (a - b c - d) - a - c - (b,d)
or
f :: (a - b a) - c - d - (b c,
PROTECTED] Em nome de Brian Hulley
Enviada: terça-feira, 10 de Janeiro de 2006 18:01
Para: Haskell-cafe
Assunto: [Haskell-cafe] Intersection types for Haskell?
Hi -
I'm wondering if there is any possiblility of getting intersection types
into Haskell. For example, at the moment there is no (proper
José Miguel Vilaça wrote:
Hi
If I understand your problem than the following is a solution:
--
{-# OPTIONS -fglasgow-exts #-}
class Foo a b where
g :: a - b
type A = {- change the following -} Int
type B = {- change the following -} Char
On 1/10/06, Brian Hulley [EMAIL PROTECTED] wrote:
Hi -
I'm wondering if there is any possiblility of getting intersection types
into Haskell. For example, at the moment there is no (proper) typing for:
f g x y = (g x, g y)
Ideally, I'd like to be able to write:
f:: (a - b c - d)
Taral wrote:
On 1/10/06, Brian Hulley [EMAIL PROTECTED] wrote:
Hi -
I'm wondering if there is any possiblility of getting intersection
types into Haskell. For example, at the moment there is no (proper)
typing for:
f g x y = (g x, g y)
Ideally, I'd like to be able to write:
f:: (a -
Brian Hulley wrote:
Taral wrote:
I have no idea what kind of function would have type (a - b c -
d). Can you give an example?
g x = x
because g 3 = 3 so g has type Int - Int but also g 'a' = 'a' so g
has type Char - Char hence g has type Int - Int Char - Char
Actually I should have said
Brian Hulley wrote:
snip
which is perhaps clearer and prevents bad types such as (Int -
String Int - Char) by construction.
Oops! I forgot that functions with such types can exist via multi-parameter
type classes and overloading - this may be one reason why intersection types
have not yet
Brian Hulley writes:
Also, as a second point, could functional dependencies in type
classes be written using a similar syntax eg instead of
class Insert t c a | c a - t where
insert :: t - c a - c a
we could write:
class Insert (h (c a)) c a where
insert :: h