Skip to content

Add generic representation type RepDeep so that DerivingVia can derive instances for LeafTree via Free []

Motivation

Coercing between types that are equal modulo bottoms like Bool and Either () () doesn't work, because the possible values differ:

  • For Either () (): ⊥, Left ⊥, Right ⊥, Left (), Right ()
  • For Bool: ⊥, False, True

Or also for data LeafTree a = Leaf a | Branch [LeafTree a], which can't be coerced to Free [] a.

Proposal

Add generic representation types RepDeep and RepDeep1 to GHC.Generics, which recursively evaluates the representations of all pointers. Then users can write

data LeafTree a = ... deriving (Applicative, Monad) via LeafTree `GenericallyDeep1As` (Free []).
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information