implicit params in instance contexts

Shachaf Ben-Kiki shachaf at gmail.com
Tue Jul 16 10:29:33 CEST 2013


On Mon, Jul 15, 2013 at 11:21 PM, Ganesh Sittampalam <ganesh at earth.li> wrote:
> Hi,
>
> It seems that from GHC 7.4, the prohibition on implicit parameter
> constraints in instance declarations has been relaxed. The program below
> gives the error "Illegal constraint ?fooRev::Bool" in GHC 7.2.1 but
> loads fine in GHC 7.4.2 and GHC 7.6.2.
>
> I can't spot anything about this in the release notes, and the
> documentation
> (http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/other-type-extensions.html#idp49069584)
> still says "You can't have an implicit parameter in the context of a
> class or instance declaration."
>
> So I wonder if this happened by accident, perhaps as part of the
> ConstraintKinds work or similar?
>
> I've wanted this feature a few times so if it's going to stay I might
> start using it. However it is a bit dangerous, so if it was added by
> accident it might warrant some discussion before deciding to keep it.
> For example as the value "set2" below shows, it can be used to violate
> datatype invariants.
>

There was a post about this previously:
http://joyoftypes.blogspot.com/2013/01/using-compiler-bugs-for-fun-and-profit.html
And a GHC ticket: http://ghc.haskell.org/trac/ghc/ticket/7624
See also the discussion at
http://www.reddit.com/r/haskell/comments/178w9u/using_compiler_bugs_for_fun_and_profit/

    Shachaf




More information about the Glasgow-haskell-users mailing list