Changes between Initial Version and Version 1 of Ticket #5248


Ignore:
Timestamp:
Jun 9, 2011 7:15:05 PM (4 years ago)
Author:
simonpj
Comment:

I'm sorry but that's the way Haskell is. You could imagine some form like

instance (...) => Foo (Bar f) where
  foo a = ...

meaning "please infer the context for me". This would be useful for type signatures more generally. For example:

f :: (...) => [a] -> String
f xs = show (sum xs)

Here the full type signature would be

f :: (Num a, Show a) => [a] -> String

This has come up before but I can't find a ticket for it, so I'll treat this as it.

Simon

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #5248

    • Property Summary changed from Infer type context from type or data constructor to Infer type context in a type signature
  • Ticket #5248 – Description

    initial v1  
    1111}}}
    1212
    13 GHC will demand Foo f => on the instance declaration, even though this can be inferred from the definition of Bar.
     13GHC will demand `Foo f =>` on the instance declaration, even though this can be inferred from the definition of Bar.
    1414
    1515I understand ''why'' this is happening, but it should not be necessary to repeat information already given. Some code violates DRY dozens of times because of this limitation.