Tracholar Zuo
Tracholar Zuo

Reputation: 467

Convert strings to values of my type fail

I defined a typeclass Vector as

data Vector a = Vector a a a deriving (Show, Read)

But when I convert from strings using code

read "Vector 1 2 3" :: Vector

It does not work. Can anyone help. Thanks!

Upvotes: 0

Views: 47

Answers (1)

chi
chi

Reputation: 116139

Vector is not a type, but a type constructor. Vector Int, Vector Double, Vector (Vector String) are types. Use

read "Vector 1 2 3" :: Vector <<some type here>>

Upvotes: 5

Related Questions