Skip to content
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

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

Open
zarakshR opened this issue Mar 5, 2024 · 0 comments
Open

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

zarakshR opened this issue Mar 5, 2024 · 0 comments

Comments

@zarakshR
Copy link

zarakshR commented Mar 5, 2024

For this example code -

{-# 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
   |           ^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant