[bitc-dev] Vectors with mutable elements

Jonathan S. Shapiro shap at eros-os.org
Fri May 19 01:09:18 EDT 2006


So apparently the existence of the Integral type class lets us "solve"
this for integer literals (sort of).

Now how do I initialize a vector of mutable characters?

Do we want to introduce a type class for each literal type (even if only
conceptually)?

On Fri, 2006-05-19 at 00:47 -0400, Swaroop Sridhar wrote:
> With the Integral typeclass defined without mutable elements as [*]:
> 
>    (deftypeclass (Integral 'a))
> 
>    (definstance (Integral int8))
>    (definstance (Integral int16))
>    (definstance (Integral int32))
>    (definstance (Integral int64))
>    (definstance (Integral uint8))
>    (definstance (Integral uint16))
>    (definstance (Integral uint32))
>    (definstance (Integral uint64))
>    (definstance (Integral word))
> 
> I the following example:
> 
> Here is the example I tried.
> 
> (define x:(vector (mutable int32)) (vector 1 2 3))
> (define y (vector (the (mutable int32) 1) 2 3))
> 
> (define xyz (set! (vector-nth x 0)  25))
> 
> The definitions of both x and y failed to type check for the want of an 
> instance (Integral (mutable int32))
> 
> Once I added the corresponding mutable counterparts as instances to the 
> prelude, both the definitions and the set! in xyz typecheck OK.
> 
> 
> [*] I have not committed this because the later phases are not yet working.
> 
> Swaroop.



More information about the bitc-dev mailing list