Reputation: 1683
I'd like to wrap some of the types of Data.Vec
in my own types but it doesn't seem to work. For example, I'd like to have my own Vec3
that would be a Vec3F
so I did something like this:
Types.h:
module Types
( Vec3(..)
) where
import qualified Data.Vec as V
type Vec3 = V.Vec3 Float
Main.hs:
import Types
vect :: Vec3
vect = Vec3 3 2 4
main = return ()
GHC complains and gives me this error:
Main.hs:4:8: Not in scope: data constructor `Vec3'
Is it because my new type has the same name as a type of Data.Vec
despite the fact that I did a qualified import?
If so is there way of doing this without changing the name of my type?
If not, how can I export from my Types
module only some types of Data.Vec
?
Upvotes: 2
Views: 62
Reputation: 44706
Vec3
is not a data constructor, it's a type (in this case, a class
). Perhaps you could wrap your own wrapper around the constructor to achieve what you want?
makeVec :: (Double,Double,Double) -> Vec3
makeVec = V.fromXYZ -- TODO some float mangling
Upvotes: 1