Nope, that's still not right... this might be the first time I have found
myself wanting ad-hoc overloading :-)

Keean.

On 9 January 2015 at 08:57, Keean Schupke <[email protected]> wrote:

> Hmm, of course I meant:
>
> class Assignable x where
>     (=) :: x -> x -> IO ()
>
> class Assignable_Const x where
>     (=) :: x -> Const x -> IO ()
>
>
> Keean.
>
> On 9 January 2015 at 08:55, Keean Schupke <[email protected]> wrote:
>
>> They do need to be part of the type system because their misuse leads
>>> to unsoundness, but requiring that different classifications of
>>> mutability be distinct types seems to lead to awkwardness when you're
>>> just trying to implement something with reasonable variance over
>>> mutability.
>>
>>
>> Surely you just need a 'const' type as in C++, and if you cannot cast
>> away const (you can only cast to const) it seems safe.
>>
>> So:
>>
>> instance Assignable x where
>>     (=) :: x -> x -> IO ()
>>
>> instance Assignable x where
>>     (=) :: x -> Const x -> IO ()
>>
>> then:
>>
>> Const Int  // immutable value
>> Const (Pointer Int) // an immutable pointer to a mutable value
>> Pointer (Const Int) // a mutable pointer to an immutable value
>> etc...
>>
>>
>> Keean.
>>
>>
>>
>>
>>
>>
>
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to