lists with mixed types

If I define something like this: data Bar = Bi Int | Bf String deriving Show data Foo = Fi Int | Fs Float deriving Show func::Foo -> Bar func (Fi xx) = Bi xx func (Fs ff) = Bf (show ff) I can do:
map func [(Fi 1), (Fs 2.0)] [Bi 1,Bf "2.0"]
but what i really want to do is just do map func [1, 2.0] [1, "2.0"] I understand that this is impossible in haskell, but why cant the compiler generate the Foo and Bar data types for me and just require that i have a func defined for Int -> Int and Float -> String?

Well, in this example I don't see how this would even be close to possible.
How would it know that 1 is supposed to be an Int a2.0 a Float? 1 has type
'Num a => a' and 2.0 has type 'Fractional a => a' so how the compiler know
you want Int and Float?
-- Lennart
On 6/16/07, Anatoly Yakovenko
If I define something like this:
data Bar = Bi Int | Bf String deriving Show
data Foo = Fi Int | Fs Float deriving Show
func::Foo -> Bar func (Fi xx) = Bi xx func (Fs ff) = Bf (show ff)
I can do:
map func [(Fi 1), (Fs 2.0)] [Bi 1,Bf "2.0"]
but what i really want to do is just do map func [1, 2.0] [1, "2.0"]
I understand that this is impossible in haskell, but why cant the compiler generate the Foo and Bar data types for me and just require that i have a func defined for Int -> Int and Float -> String? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (2)
-
Anatoly Yakovenko
-
Lennart Augustsson