You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
piu 2010-11-01
instance JSON [Char] needs the FlexibleInstances pragma,
instance JSON String needs the TypeSynonymInstances pragma.
these are different problems, I think, even if they might often be related.
simple example:
----------------------
given the following type and typeclass:
data (Num a) => Vector a = Vector a a
deriving (Show)
class MyClass a where
myFun :: a -> a
it seems perfectly ok to define (without the need of any pragma)
instance MyClass (Vector a) where
myFun = id
myFun (Vector 1 2) :: Vector Int gives Vector 1 2, myFun (Vector 1 2) :: Vector Double gives Vector 1.0 2.0 instead.
but if you try to define
instance MyClass (Vector Int) where etc…
instance MyClass (Vector Double) where etc…
- perhaps because you want to handle those types of vectors differently - you will need the FlexibleInstances pragma. and if you try to work around this problem by introducing two new type synonyms
type VectorInt = Vector Int
type VectorDouble = Vector Double
and using them in the instance declaration
instance MyClass VectorInt where etc…
you will need the TypeSynonymInstances pragma instead.
No description provided.
The text was updated successfully, but these errors were encountered: