Skip to content
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: An injectivity annotation must put the type family's result variable on the left-hand side.
severity: error
introduced: 9.6.1
---

This error occurs when the variable on the left-hand side of an injectivity annotation is not the type family's result variable.

Type families in Haskell define type-level functions. In `type family F a = r | r -> a`, the injectivity annotation `| r -> a` states that the result type `r` uniquely determines the input type `a`: equal results imply equal inputs. The left-hand side must be the result variable `r` named after `=`, and the right-hand side lists the input variables determined by that result.
Loading