Hi,
I am comparing Haskell's class/instance techniques for overloading with those available Order Sorted Algebra (OSA in CafeOBJ)
Using just the basic class/instance mechanism is there any way to avoid the type annotations in the evaluations below?
Pat
class Location a b where
move::a->b
instance Location Int Int where
move e = e + 3
instance Location Float Int where
move e = floor(e + 3.1)
instance Location [Float] [Int] where
move [] = []
move (e:l) = (move e):(move l)
instance Location [Int] [Int] where
move [] = []
move (e:l) = (move e):(move l)
-- evaluations
-- testing float
-- (move ((7.6::Float))::Int)
-- ((move ([21.8,7.4,9.1]::[Float]))::[Int])
-- testing integers
-- move ((3::Int))::Int
-- ((move ([21,7,9]::[Int]))::[Int])
Tá an teachtaireacht seo scanta ó thaobh ábhar agus víreas ag Seirbhís Scanta Ríomhphost de chuid Seirbhísí Faisnéise, ITBÁC agus meastar í a bheith slán. http://www.dit.ie
This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie