Skip to content

Instantly share code, notes, and snippets.

@dtchepak
Created June 4, 2012 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dtchepak/2865610 to your computer and use it in GitHub Desktop.
Save dtchepak/2865610 to your computer and use it in GitHub Desktop.
Illegal instance declaration, flexible instances?
{-# LANGUAGE MultiParamTypeClasses #-}
class Collection c a where
insert :: a -> c a -> c a
instance Collection [] a where
insert a b = (a:b)
{-
Illegal instance declaration for `Collection [] a'
(All instance types must be of the form (T a1 ... an)
where a1 ... an are *distinct 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 `Collection [] a'
-}
-- http://www.haskell.org/haskellwiki/List_instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment