Donné :
data Foo =
  FooString String
  …
class Fooable a where --(is this a good way to name this?)
  toFoo :: a -> Foo
Je veux créer Stringune instance de Fooable:
instance Fooable String where
  toFoo = FooString
GHC se plaint alors:
Illegal instance declaration for `Fooable String'
    (All instance types must be of the form (T t1 ... tn)
     where T is not a synonym.
     Use -XTypeSynonymInstances if you want to disable this.)
In the instance declaration for `Fooable String'
Si à la place j'utilise [Char]:
instance Fooable [Char] where
  toFoo = FooString
GHC se plaint:
Illegal instance declaration for `Fooable [Char]'
   (All instance types must be of the form (T a1 ... an)
    where a1 ... an are type *variables*,
    and each type variable appears at most once in the instance head.
    Use -XFlexibleInstances if you want to disable this.)
In the instance declaration for `Fooable [Char]'
Question :
- Pourquoi ne puis-je pas créer une chaîne et une instance d'une classe de types?
- GHC semble prêt à me laisser m'en tirer si j'ajoute un drapeau supplémentaire. Est-ce une bonne idée?