[Haskell-cafe] How to declare a Typeless Function
magnus at therning.org
Fri Jul 3 03:54:29 EDT 2009
On Fri, Jul 3, 2009 at 4:43 AM, Alexander
Dunlap<alexander.dunlap at gmail.com> wrote:
> swap :: Array (Int, Int) a -> [Int] -> Array (Int, Int) a
> The lowercase "a" means that that type variable is polymorphic, i.e.
> it can be any type.
Another option would be to simply not put in type of 'swap', load it
in ghci and see what the compiler says the type is :-)
> On Thu, Jul 2, 2009 at 8:05 PM, Fernan Bolando<fernanbolando at mailc.net> wrote:
>> I have a function that swaps rows of an array of double
>> swap :: Array (Int,Int) Double -> [Int] -> Array (Int,Int) Double
>> I then create a function that swaps rows of arrays of Complex Double
>> swap :: Array (Int, Int) (Complex Double) -> [Int] -> Array (Int, Int)
>> (Complex Double)
>> In reality the function swap does not care whether its working on a
>> double or a complex number.
>> how do I declare swap so that it will work whether it's a complex or a
>> double array.
>> I tried googling but I wasn't sure what to google.
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnus＠therning．org Jabber: magnus＠therning．org
http://therning.org/magnus identi.ca|twitter: magthe
More information about the Haskell-Cafe