Skip to content

Add GHC-88333 #511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilyDependencies #-}

module IncorrectTypeVarLHSInjectivityCondition where

class Fcl a where
type Ft a = r | r -> a
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module IncorrectTypeVarLHSInjectivityCondition where

class Fcl a where
type Ft a = r | a -> a
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Incorrect type variable on the LHS of injectivity condition
---

In the example, the associated type family Ft is defined with an incorrect injectivity annotation. The left-hand side (LHS) of the injectivity condition should be the output type variable (r), but in the definition, it is the input type variable (a). This is what the error message is referring to.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilyDependencies #-}

module IncorrectTypeVarLHSInjectivityCondition where

type family Fc a = r | r -> a where
Fc a = a
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module IncorrectTypeVarLHSInjectivityCondition where

type family Fc a = r | a -> a where
Fc a = a
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Incorrect type variable on the LHS of injectivity condition
---

In the example, type family Fc is defined with an incorrect injectivity annotation. The left-hand side (LHS) of the injectivity condition should be the output type variable (r), but in the definition, it is the input type variable (a). This is what the error message is referring to.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilyDependencies #-}

module IncorrectTypeVarLHSInjectivityCondition where

type family F a = r | r -> a
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module IncorrectTypeVarLHSInjectivityCondition where

type family F a = r | a -> a
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Incorrect type variable on the LHS of injectivity condition
---

In the example, type family F is defined with an incorrect injectivity annotation. The left-hand side (LHS) of the injectivity condition should be the output type variable (r), but in the definition, it is the input type variable (a). This is what the error message is referring to.
10 changes: 10 additions & 0 deletions message-index/messages/GHC-88333/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Incorrect type variable on the LHS of injectivity condition
summary: Injectivity annotations are used to constrain type families, so that for a given input type, there is exactly one output type.
severity: error
introduced: 9.6.1
---

This error is about the incorrect use of type variables in the injectivity condition of type families.

Type families in Haskell are a way to define type-level functions. An injectivity annotation (| a -> r) is used to specify that for a given input type a, there is exactly one output type r that the type family can map to.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please use Markdown backticks here and elsewhere?

Suggested change
Type families in Haskell are a way to define type-level functions. An injectivity annotation (| a -> r) is used to specify that for a given input type a, there is exactly one output type r that the type family can map to.
Type families in Haskell are a way to define type-level functions. An injectivity annotation (`| a -> r`) is used to specify that for a given input type `a`, there is exactly one output type `r` that the type family can map to.

Loading