[Haskell-cafe] Why is this array use wrong?

Marc A. Ziegert coeus at gmx.de
Sat Dec 16 07:31:05 EST 2006


b needs a type.

[code]
Prelude Data.Array.IArray> :t array
array :: (Ix i, IArray a e) => (i, i) -> [(i, e)] -> a i e
Prelude Data.Array.IArray> let b = array (1,33) [(i,False) | i <- [1..33]] :: Array Int Bool
Prelude Data.Array.IArray> :t b
b :: Array Int Bool
Prelude Data.Array.IArray> b
array (1,33) [(1,False),(2,False),(3,False),(4,False),(5,False),(6,False),(7,False),(8,False),(9,False),(10,False),(11,False),(12,False),(13,False),(14,False),(15,False),(16,False),(17,False),(18,False),(19,False),(20,False),(21,False),(22,False),(23,False),(24,False),(25,False),(26,False),(27,False),(28,False),(29,False),(30,False),(31,False),(32,False),(33,False)]
Prelude Data.Array.IArray> 
[/code]

the error said:
 No instance for (IArray ...)
 arising from use of `array'

the unspecified type of b did not had this instance;
but now it has the type "Array" --and with that type the needed instance, too.

- marc



Am Samstag, 16. Dezember 2006 12:56 schrieb Maurí­cio:
>    Hi,
> 
>    I'm trying this in ghci:
> 
> let b = array (1,33) [(i,False) | i <- [1..33]]
> 
> after :m Data.Array.IArray. It gives me that error message:
> 
> <interactive>:1:8:
>      No instance for (IArray a Bool)
>        arising from use of `array' at <interactive>:1:8-12
>      Probable fix: add an instance declaration for (IArray a Bool)
>      In the definition of `b': b = array (1, 33) ([(i, False) | i <- [1 
> .. 33]])
> 
>    Why?
> 
>    Thanks,
>    Maurício
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 


More information about the Haskell-Cafe mailing list