Skip to content

Instantly share code, notes, and snippets.

@Lysxia
Created September 21, 2022 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lysxia/7714c19ef9c17b487a46c804694fc0f9 to your computer and use it in GitHub Desktop.
Save Lysxia/7714c19ef9c17b487a46c804694fc0f9 to your computer and use it in GitHub Desktop.
{-# LANGUAGE
ConstraintKinds,
FlexibleContexts,
FlexibleInstances,
MultiParamTypeClasses,
QuantifiedConstraints,
RankNTypes,
ScopedTypeVariables,
TypeApplications,
UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-simplifiable-class-constraints #-}
module DG where
import GHC.Generics
class RepFmap a a' rep rep' where
repFmap :: (a -> a') -> rep -> rep'
gfmap :: forall f a a'. GFunctor f => (a -> a') -> f a -> f a'
gfmap f =
with @(RepFmapRep a a' f) -- Hand-holding for GHC <= 9.0
(to @_ @() . repFmap f . from @_ @())
with :: forall c r. (c => r) -> (c => r)
with x = x
class (forall a. Generic (f a), forall a a'. RepFmapRep a a' f) => GFunctor f
instance (forall a. Generic (f a), forall a a'. RepFmapRep a a' f) => GFunctor f
class RepFmap a a' (Rep (f a) ()) (Rep (f a') ()) => RepFmapRep a a' f
instance RepFmap a a' (Rep (f a) ()) (Rep (f a') ()) => RepFmapRep a a' f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment