Unboxed Vectors of newtype'd values

Roman Leshchinskiy rl at cse.unsw.edu.au
Wed Jun 6 13:13:49 CEST 2012


Andres Löh wrote:
>>> Yes, because these are superclasses of Unbox. So can't you simply say
>>> this:
>>>
>>>> newtype Foo = Foo Int
>>>>   deriving (Eq, Show, Unbox, M.MVector MVector, G.Vector Vector)
>>
>> I don't think this should work. This is the basic set up:
>
> [...]
>
>> I don't understand what GeneralizedNewtypeDeriving does with
>> deriving(G.Vector Vector) in this situation but it can't possibly do
>> anything sensible without a data instance Vector Foo. The fact that it
>> doesn't fail is just a bug, IMO.
>
> I've actually started wondering the same after I posted this. I tried
> to use -ddump-deriv to get at the code, but GHC seems to be cheating
> and doesn't show what it generates. I guess I understand
> newtype-deriving less than I thought ...

I don't really understand it, either, and try to stay well away from it
:-) It simply doesn't seem to work with GADTs, type families etc. I've
created a ticket: http://hackage.haskell.org/trac/ghc/ticket/6147.

Roman






More information about the Libraries mailing list