Skip to content

Allow default methods to be implemented using template haskell

In conversations with @kosmikus he suggested that it would be nice to integrate default implementations with typed template haskell.

For example,

class Eq a where
    eq :: a -> a -> Bool

    default splice eq :: Generic a => Code (a -> a -> Bool)
    eq = _impl_

This has the massive advantage that the default implementation can be efficient than the usual Data or Generics based implementations.

There would need to be a GHC proposal related to this ticket but I write it down here in case anyone else finds it interesting.

Related to #12457

Edited by Matthew Pickering
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information