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 instance Foo A B where g a = {- change the following -} ' ' type C = {- change the following -} Float type D = {- change the following -} String instance Foo C D where g c = {- change the following -} "" f :: (Foo a b, Foo c d) => a -> c -> (b, d) f x y = (g x, g y) --------------------------------------------------------- Simply create a class an give instances for the wanted types. The code above is also in a file in attachment. cheers José Miguel Vilaça Departamento de Informática - Universidade do Minho [EMAIL PROTECTED] -----Mensagem original----- De: [EMAIL PROTECTED] [mailto:[EMAIL 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) 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, b d) which is perhaps clearer and prevents bad types such as (Int -> String & Int -> Char) by construction. While it may be impossible (?) to infer such a type for f, would it be possible to make use of such an annotation (esp since Haskell with GHC extensions already has arbitary rank polymorphism)? 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 (c a) -> c a -> c a or class Insert t@(h (c a)) c a where -- re-using as-pattern syntax insert :: t -> c a -> c a to avoid having to have a special syntax just for functional dependencies and/or to be able to write more complicated fundeps more succinctly? Regards, Brian Hulley _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
tep.hs
Description: Binary data
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe