Skip to content

Unnecessary constraints in inferred type

Carter Schonwald reports: when playing with the current hackage versions of Epic and Idris to make them play nice with ghc7.6rc1

I ran into some funny type inference problems. Namely, using the idris-0.9.2.1 source and iteratively seeing how ghc complains, I repeated found that ghc would infer extraneous class constraints with variables that don't appear in the function type! eg (Num a, Ord a) => PArg -> Doc, when the correct type to infer would be PArg -> Doc.

Here are some gists with links to more info https://gist.github.com/3365312 https://gist.github.com/3365073 https://gist.github.com/3364775 Anyways, I'm not sure what to make of this, is this a reasonable artifact of type inference getting confused on functions with a large number of case analyses when various typeclass extensions are enabled? Or Is this a bug in terms of what inference should be able to handle?

Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information