[Haskell-beginners] Type Inference

Johannes Engels johannes.engels at hft-stuttgart.de
Thu Jan 17 08:41:31 CET 2013


Am 16.01.2013 23:48, schrieb Lemol Morais Lutonda:
>
> You realy need a generic indtype? what if to define it just as a Int?
>
>
> 48 Aniversario del Instituto Superior Politecnico Jose Antonio 
> Echeverria, Cujae
> Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | 
> http://cujae.edu.cu
>
>
> Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu
>

You are right that I don't need a generic indtype in the instance 
declarations, the following would be sufficient for me:

 > instance Sliceable (UArray Int Double) Int Double
 >    where (!) = (AU.!)

 > instance Sliceable (UArray Int Double) [Int] (UArray Int Double)
 >    where (!) arr ilist = listArray (0,end_ind) [(AU.!) arr i | i <- 
ilist]
 >               where end_ind = length ilist - 1

But also for this case a type annotation is necessary as in my original 
post. And within the class definition I think I need a generic indtype, 
because I want to be able to use arguments of type Int as well as [Int] 
as the second argument of (!).






More information about the Beginners mailing list