[Haskell-cafe] Creating Repa arrays from unboxed vectors

14 views
Skip to first unread message

Janek S.

unread,
Oct 4, 2012, 6:50:10 AM10/4/12
to haskel...@haskell.org
Dear list,

I'm trying to create unboxed REPA array from unboxed Vector, but I keep getting this type error:

ghci> :m + Data.Array.Repa
ghci> :m + Data.Array.Repa.Repr.Unboxed
ghci> :m + Data.Vector.Unboxed
ghci> fromUnboxed Z (Data.Vector.Unboxed.singleton 1)

<interactive>:5:16:
Couldn't match expected type `vector-0.9.1:Data.Vector.Unboxed.Base.Vector
e0'
with actual type `Data.Vector.Unboxed.Vector a0'
In the return type of a call of `Data.Vector.Unboxed.singleton'
In the second argument of `fromUnboxed', namely
`(Data.Vector.Unboxed.singleton 1)'
In the expression: fromUnboxed Z (Data.Vector.Unboxed.singleton 1)

I am confused, because REPA documentation lists Vector from Data.Vector.Unboxed package as its
second parameter. Why am I getting this error? I have Repa 3.2 an vector 0.9.1.

Janek

_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Ivan Lazar Miljenovic

unread,
Oct 4, 2012, 7:10:03 AM10/4/12
to Janek S., haskel...@haskell.org
On 4 October 2012 20:50, Janek S. <freme...@poczta.onet.pl> wrote:
> Dear list,
>
> I'm trying to create unboxed REPA array from unboxed Vector, but I keep getting this type error:
>
> ghci> :m + Data.Array.Repa
> ghci> :m + Data.Array.Repa.Repr.Unboxed
> ghci> :m + Data.Vector.Unboxed
> ghci> fromUnboxed Z (Data.Vector.Unboxed.singleton 1)
>
> <interactive>:5:16:
> Couldn't match expected type `vector-0.9.1:Data.Vector.Unboxed.Base.Vector
> e0'
> with actual type `Data.Vector.Unboxed.Vector a0'
> In the return type of a call of `Data.Vector.Unboxed.singleton'
> In the second argument of `fromUnboxed', namely
> `(Data.Vector.Unboxed.singleton 1)'
> In the expression: fromUnboxed Z (Data.Vector.Unboxed.singleton 1)

This makes it look like you've got two versions of vector installed,
with Repa built against the version that _isn't_ 0.9.1.

>
> I am confused, because REPA documentation lists Vector from Data.Vector.Unboxed package as its
> second parameter. Why am I getting this error? I have Repa 3.2 an vector 0.9.1.
>
> Janek
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskel...@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



--
Ivan Lazar Miljenovic
Ivan.Mi...@gmail.com
http://IvanMiljenovic.wordpress.com

Janek S.

unread,
Oct 4, 2012, 7:58:12 AM10/4/12
to haskel...@haskell.org
Thanks!

> This makes it look like you've got two versions of vector installed,
This is true, I have vector-0.9.1 and vector-0.10, but
> with Repa built against the version that _isn't_ 0.9.1.
this, I think, is not exactly correct:

[root@GLaDOS : /dane/download] ghc-pkg field repa depends
depends: QuickCheck-2.4.2-41cb2884cc20cd78948de62849bd9667
base-4.5.0.0-6db966b4cf8c1a91188e66d354ba065e
bytestring-0.9.2.1-18f26186028d7c0e92e78edc9071d376
ghc-prim-0.2.0.0-c2ff696e5b8ec4d4b2bc2e42085fe471
template-haskell-2.7.0.0-133c0fdb189e05de22bd926d39f99fe3
vector-0.9.1-04dd5c58c224b03a4dc90091cf93a01d

So Repa is build againts 0.9.1. Everything works when I do "ghc-pkg hide vector-0.10.0". Is there
a way to tell GHCi which version of library it should load? I tried -XPackageImports but it
doesn't allow to specify version of a package, only its name (or I don't know how to specify
version).

Jan

Chaddaï Fouché

unread,
Oct 4, 2012, 8:42:01 AM10/4/12
to Janek S., haskel...@haskell.org
On Thu, Oct 4, 2012 at 1:58 PM, Janek S. <freme...@poczta.onet.pl> wrote:
> Thanks!
>
>> This makes it look like you've got two versions of vector installed,
> This is true, I have vector-0.9.1 and vector-0.10, but
>> with Repa built against the version that _isn't_ 0.9.1.

No, no, Repa is build against 0.9.1 since vector-0.9.1 appears in the
_expected_ type, that is the type expected by the environment of the
expression, here that's fromUnboxed which comes from the Repa library,
so if it's waiting for a Vector from vector-0.9.1 it means Repa is
built against this version (which is not the latest on your computer
thus the problem).

--
Jedaï

Janek S.

unread,
Oct 4, 2012, 10:04:05 AM10/4/12
to Chaddaï Fouché, haskel...@haskell.org
> so if it's waiting for a Vector from vector-0.9.1 it means Repa is
> built against this version (which is not the latest on your computer
> thus the problem).
Yes, as I said the latest one is 0.10. Is there any way to sensibly manage this kind of
dependencies (sensibly = without hidding packages manually).

Jan

Michael Sloan

unread,
Oct 4, 2012, 9:49:32 PM10/4/12
to Janek S., haskel...@haskell.org

Hello!

Perhaps package imports would do the trick?

http://haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#package-imports

Not exactly something you'd want to release in a module in a hackage package, though.

-Michael

Reply all
Reply to author
Forward
0 new messages