Hi. I'm working downstream at https://github.com/ConferOpenSource/composite and trying to use the :-> operator in XRec expressions. I was able to get currying working by defining.
instance KnownSymbol s => IsoHKD Identity (s :-> a) where
type HKD Identity (s :-> a) = a
unHKD = Identity . Val
toHKD (Identity (Val x)) = x
However this isn't particularly good, because this is against a different Identity declaration so it coincidentally doesn't conflict. However if I try to do for example this HKD which is what I'm using.
instance Functor m => IsoHKD (ReaderT r m) a where
type HKD (ReaderT r m) a = r -> m a
unHKD f = ReaderT $ f
toHKD (ReaderT f) = f
instance Functor m => IsoHKD (ReaderT r m) (s :-> a) where
type HKD (ReaderT r m) (s :-> a) = r -> m a
unHKD f = ReaderT $ f
toHKD (ReaderT f) = f
Then I get an overlapping instance error.
/home/lc/Source/gitlab.com/shakebook-site/shakebook-lib/test/Spec.hs:90:8: error:
Conflicting family instance declarations:
HKD (ReaderT r m) a = r -> m a -- Defined at test/Spec.hs:90:8
HKD (ReaderT r m) (s :-> a) = r -> m a
-- Defined at test/Spec.hs:95:8
|
90 | type HKD (ReaderT r m) a = r -> m a
I can't simply copy the ELField example because the constructor for :-> is not a pair, and is defined like
newtype (:->) (s :: Symbol) a = Val { getVal :: a }
So defining
instance KnownSymbol s => IsoHKD ((:->) s) a where
type HKD ((:->) s) a = a
unHKD x = Val x
toHKD (Val x) = x
isn't actually the right behaviour because the type is not actually part of the functor, it's part of the record field. Is there a right way to do this?
Hi. I'm working downstream at https://github.com/ConferOpenSource/composite and trying to use the
:->operator in XRec expressions. I was able to get currying working by defining.However this isn't particularly good, because this is against a different Identity declaration so it coincidentally doesn't conflict. However if I try to do for example this HKD which is what I'm using.
Then I get an overlapping instance error.
I can't simply copy the ELField example because the constructor for :-> is not a pair, and is defined like
So defining
isn't actually the right behaviour because the type is not actually part of the functor, it's part of the record field. Is there a right way to do this?