Since it seems that writing a ListIsomorphic
instance for generic vectors is impossible (or not a good idea), I'm trying to write one for Vector.Unboxed
directly.
class ListIsomorphic l where
toList :: l a -> [a]
fromList :: [a] -> l a
instance ListIsomorphic UV.Vector where
toList = UV.toList
fromList = UV.fromList
I'm getting the following error:
test.hs:70:14:
No instance for (UV.Unbox a) arising from a use of ‘UV.toList’
Possible fix:
add (UV.Unbox a) to the context of
the type signature for toList :: UV.Vector a -> [a]
In the expression: UV.toList
In an equation for ‘toList’: toList = UV.toList
In the instance declaration for ‘ListIsomorphic UV.Vector’
test.hs:71:16:
No instance for (UV.Unbox a) arising from a use of ‘UV.fromList’
Possible fix:
add (UV.Unbox a) to the context of
the type signature for fromList :: [a] -> UV.Vector a
In the expression: UV.fromList
In an equation for ‘fromList’: fromList = UV.fromList
In the instance declaration for ‘ListIsomorphic UV.Vector’
I've tried following the compiler error advice but it didn't work. How can I write it?