[Haskell-cafe] MultiParamTypeClasses, FunctionalDependencies and FlexibleInstances using GHCi

Stephen Tetley stephen.tetley at gmail.com
Fri May 14 09:33:24 EDT 2010


Hi Julian

Variations of this one come up quite often, in a nutshell the
typechecker doesn't use the instance context in the way you are
expecting:

> instance (Prelude.Num x) => Num x x x where
           ^^^^^^^^^^^^^^^
           instance context

GHC takes less notice of the context than you might expect. Quite how
much notice it takes I'm finding had to establish from section 7.6 of
the user guide (Section 7.6.3.4. - Overlapping instances - appears to
indicate it might even take none, though maybe my reading is missing
something). Hopefully someone else will provide a definitive answer
soon.


http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/type-class-extensions.html

Best wishes

Stephen


More information about the Haskell-Cafe mailing list