Skip to content

Instantly share code, notes, and snippets.

@msakai
Last active Aug 4, 2020
Embed
What would you like to do?
Interaction of ConstraintKinds and QuantifiedConstraints. There was already an issue about it https://gitlab.haskell.org/ghc/ghc/-/issues/16139 .
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE QuantifiedConstraints #-}
data Rose f a = Branch a (f (Rose f a))
type Eq1 f = (forall b. Eq b => Eq (f b))
{-
ng.hs:6:33: error:
• Expected a type, but ‘Eq (f b)’ has kind ‘Constraint’
• In the type ‘(forall b. Eq b => Eq (f b))’
In the type declaration for ‘Eq1’
|
6 | type Eq1 f = (forall b. Eq b => Eq (f b))
| ^^^^^^^^
Failed, no modules loaded.
-}
instance (Eq a, Eq1 f) => Eq (Rose f a) where
Branch x1 c1 == Branch x2 c2 = x1==x1 && c1==c2
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE QuantifiedConstraints #-}
data Rose f a = Branch a (f (Rose f a))
instance (Eq a, forall b. Eq b => Eq (f b)) => Eq (Rose f a) where
Branch x1 c1 == Branch x2 c2 = x1==x1 && c1==c2
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes #-}
import Data.Kind
data Rose f a = Branch a (f (Rose f a))
type Eq1 f = (forall b. Eq b => Eq (f b)) :: Constraint
instance (Eq a, Eq1 f) => Eq (Rose f a) where
Branch x1 c1 == Branch x2 c2 = x1==x1 && c1==c2
resolver: nightly-2020-08-03
packages: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment