
#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: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): I am far from an expert on source plugins, so I can't say whether this is possible or not. But my initial reaction is: sure, why not? I could imagine an API like this: {{{#!hs type Derived a = a class Foo a where ... data Bar deriving (Derived Foo) }}} Here, the use of `Derived` is a syntactic clue to a source plugin to derive this using some custom functionality (instead of just trying to derive `Foo` normally). To make this robust, you'd likely need to borrow some of GHC's own logic for `deriving` type classes. Luckily, GHC already exposes much of this! See the `TcDeriv`, `TcGenDeriv`, and `TcDerivUtils` modules. I certainly don't have the time to try this out myself, but I'd be happy point any volunteers in the right direction. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15650#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler