[Haskell-cafe] Trying to use more than one array in runSTUArray

Juan Miguel Vilar jvilar at uji.es
Thu Mar 15 23:50:04 CET 2012


El 15/03/12 20:07, Daniel Fischer escribió:
> On Thursday 15 March 2012, 19:53:56, Daniel Fischer wrote:
>> On Thursday 15 March 2012, 19:27:18, Juan Miguel Vilar wrote:
>>> Hello, café:
>
>>
>>> However, when I write
>>>
>>> test2 n = runSTUArray $ do
>>>
>>>                let createArray v n = newArray (1, n) (v::Int)
>>
>> Here you create a local binding for createArray that gets a monomorphic
>> type, that type is the fixed by the returning of b to
>>
>> createArray :: Int ->  Integer ->  ST s (STUArray s Integer Int)
>>
>> you can make that fail too with enabling {-# LANGUAGE NoMonoLocalBinds
>> #-}
>
> Hmm, what compiler version are you using? When I actually tried to compile
> that, it failed with
>
>      No instance for (MArray a0 Int (ST s))
>
> without language extensions. After enabling MonoLocalBinds, however, it
> compiled with 6.12.3, 7.0.2, 7.0.4, 7.2.1 and 7.2.2, but 7.4.1 still
> refused to compile it.
>

I am using 7.0.3. Adding type signatures solved the problems. And with 
respect to MonoLocalBinds, it failed after adding NoMonoLocalBinds, 
without it, everything went fine.

   Thanks a lot,

   Juan Miguel

-- 
Juan Miguel Vilar Torres
Profesor titular de universidad
Vicedirector de la ESTCE para ITIG e ITIS
Departamento de Lenguajes y Sistemas Informáticos
Escuela Superior de Tecnología y Ciencias Experimentales
Universitat Jaume I
Av. de Vicent Sos Baynat s/n
12071 Castelló de la Plana (Spain)
Tel: +34 964 72 8365
Fax: +34 964 72 8435
jvilar at lsi.uji.es



More information about the Haskell-Cafe mailing list