
#12923: MultiParamTypeClasses + ExtendedDefaultRules -------------------------------------+------------------------------------- Reporter: amindfv | Owner: Type: feature request | Status: patch Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2822 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): The proposed new defaulting rules in the patch are: Find all the unsolved constraints. Then: * Find those of form `(C t1 ... a ... tn)`, where `C` is a class, and `a` is a type variable of kind `Type` or `(Type -> Type)`, and all the other parameters of `C` have kinds other than `Type` or `Type -> Type`. * Partition this set into groups that share a common type variable `a`. * Now default `a` (to one of the types in the default list) if * The type variable `a` appears in no other constraint outside that group * At least one of the classes `Ci` is an interactive class ("Interactive class" is defined [http://downloads.haskell.org/~ghc/master /users-guide/ghci.html#type-defaulting-in-ghci here].) This seems a bit complicated to me. What about this instead. Find all the unsolved constraints. Then: * Find those that have exactly one free type variable, and partition that subset into groups that share a common type variable `a`. * Now default `a` (to one of the types in the default list) if at least one of the classes `Ci` is an interactive class This is a bit more flexible, and a bit simpler to describe. The "just one free type variable" part is meant to avoid having to look for ''combinations'' of defaulting types that will allow the constraint to be solved. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12923#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler