Expose a generic rep for HKD

All we do is expose the internal rep "as" the generic rep. I need to do
a bit of experimentation, but this _might_ actually make the generic
lenses here redundant...
This commit is contained in:
Tom Harding 2019-06-15 18:19:51 +01:00
parent 7527a89678
commit b34a9c707e

View File

@ -34,6 +34,7 @@ module Data.Generic.HKD.Types
import Data.Barbie (ConstraintsB (..), FunctorB (..), ProductB (..), ProductBC (..), TraversableB (..))
import Data.Barbie.Constraints (Dict (..))
import Data.Function (on)
import Data.Functor.Contravariant (Contravariant (..), phantom)
import Data.Functor.Product (Product (..))
import Data.Kind (Constraint, Type)
import Data.Proxy (Proxy (..))
@ -82,6 +83,13 @@ import Test.QuickCheck.Function (Function (..), functionMap)
newtype HKD (structure :: Type) (f :: Type -> Type)
= HKD { runHKD :: HKD_ f structure Void }
instance (Contravariant (HKD_ f structure), Functor (HKD_ f structure))
=> Generic (HKD structure f) where
type Rep (HKD structure f) = HKD_ f structure
from = phantom . runHKD
to = HKD . phantom
-------------------------------------------------------------------------------
-- | Calculate the "partial representation" of a type.