Skip to content

Superclass does not be inherited if same constraint was applied to different type parameter #3431

Description

@acple

minimal repro code is here:

class (Functor f, Functor g) <= MyClass f g

fff :: forall f g. MyClass f g => f ~> f
fff = map identity -- Err, No type class instance was found for Functor f

ggg :: forall f g. MyClass f g => g ~> g
ggg = map identity -- ok
-- swap definition order f <-> g
class (Functor g, Functor f) <= MyClass f g

fff :: forall f g. MyClass f g => f ~> f
fff = map identity -- ok

ggg :: forall f g. MyClass f g => g ~> g
ggg = map identity -- Err, No type class instance was found for Functor g

and other examples:

-- g is not `Apply`
class (Apply f, Functor g) <= MyClass f g

ffff :: forall f g a b. MyClass f g => f (a -> b) -> f a -> f b
ffff = apply -- ok
-- g implies `Apply`
class (Apply f, Applicative g) <= MyClass f g

ffff :: forall f g a b. MyClass f g => f (a -> b) -> f a -> f b
ffff = apply -- Err, No type class instance was found for Apply f

purs 0.12.0 on macOS High Sierra 10.13.6 and Windows 10 Pro 1803

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions