[GHC] #15650: Add (or document if already exist) ability to derive custom typeclasses via source plugins

GHC ghc-devs at haskell.org
Mon Sep 17 12:37:30 UTC 2018


#15650: Add (or document if already exist) ability to derive custom typeclasses via
source plugins
-------------------------------------+-------------------------------------
        Reporter:  chshersh          |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.6.1-beta1
      Resolution:                    |             Keywords:  source
                                     |  plugins,deriving,typeclass
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by mpickering):

 * related:  #12457 =>


Comment:

 I have been playing around with this problem this morning. There are some
 engineering issues to do with the phase ordering. Plugins run at the end
 of the specific phase so you need to at least run a renamer plugin to
 remove the instances like `Derived Foo` from the deriving list. Then you
 probably need to also to implement a type checker plugin to solve the
 instances you are yet to create and
 finally, actually generate the instances with `TcDeriv` and so on.

 One way around this might be to implement the deriving all in a renamer
 plugin as then you can
 just directly generate the `instance Foo a where..` syntax and pass it
 into the type checker. Now typing this out, this seems a more robust and
 easy solution to implement.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15650#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list