haskellfoundation / haskellfoundation/error-message-index

GHC-40564 "Inaccessible code in..." is undocumented

Open
#480 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
108
Forks
71
PR merge metrics
No merged PRs in 30d

Description

For this example code -

```haskell
{-# LANGUAGE GADTs #-}

data HList a where
HNil :: HList ()
HCons :: head -> HList tail -> HList (head, tail)

exampleHList :: HList (String, (Int, (Bool, ())))
exampleHList = HCons "Tom" (HCons 25 (HCons True HNil))

hListHead :: HList (a,b) -> a
hListHead HNil = undefined
hListHead (HCons head tail) = head

```

`ghc 9.0.2` provides the following undocumented warning -

```
example.hs:11:11: warning: [-Winaccessible-code]
• Couldn't match type ‘(a, b)’ with ‘()’
Inaccessible code in
a pattern with constructor: HNil :: HList (),
in an equation for ‘hListHead’
• In the pattern: HNil
In an equation for ‘hListHead’: hListHead HNil = undefined
• Relevant bindings include
hListHead :: HList (a, b) -> a (bound at example.hs:11:1)
|
11 | hListHead HNil = undefined
| ^^^^
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.