[Haskell-cafe] Overloading functions based on arguments?
ekirpichov at gmail.com
Fri Feb 13 05:25:27 EST 2009
class Foobar a b where
foobar :: a -> b -> Int
instance Foobar String Int where ...
instance Foobar Int String where ...
2009/2/13 Daniel Kraft <d at domob.eu>:
> I just came across a problem like this: Suppose I've got two related
> functions that do similar things, and I want to call them the same... Like
> foobar :: String -> Int -> Int
> foobar :: Int -> String -> Int
> (Bad example, but I hope you got the point.)
> Is this kind of overloading (instead of the polymorphism based overloading)
> possible in Haskell? Namely to have two functions with the same name but
> different signatures so they could be distinguished by a call's parameters?
> I fear not... So I guess I have to name the functions differently, right?
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe