quantified-constraints

Quantified constraints vs. (closed) type families

吃可爱长大的小学妹 提交于 2021-02-04 17:24:08
问题 I am trying to use this blogpost's approach to higher-kinded data without dangling Identity functors for the trival case together with quantified-constraint deriving: {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE QuantifiedConstraints, StandaloneDeriving, UndecidableInstances #-} module HKD2 where import Control.Monad.Identity type family HKD f a where HKD Identity a = a HKD f a = f a data Result f = MkResult { foo :: HKD f Int , bar :: HKD f Bool } deriving instance (forall a. Show a => Show

Why is using QuantifiedConstraints to specify a subclass of a typeclass also demanding an instance of the subclass?

主宰稳场 提交于 2020-01-03 15:58:11
问题 I'm playing around with a multikinded tagless encoding of Free {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE QuantifiedConstraints #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE TypeOperators #-} module Free where import GHC.Types type (a :: k) ~> (b :: k) = Morphism k a b newtype Natural (f :: j -> k) (g :: j -> k) = Natural {