Skip to content

A typo in the GHC user's guide, section 6.5.8.2

Summary

the GHC user's guide

section 6.5.8.2

Syntax highlighting is broken due to a typo

Proposed improvements or changes

Should be:

data Record (xs :: [(k, Type)]) where
  Nil  :: Record '[]
  Cons :: Proxy x -> a -> Record xs -> Record ('(x, a) ': xs)

instance HasField x (Record ('(x, a) ': xs)) a where
  getField (Cons _ v _) = v
instance HasField x (Record xs) a => HasField x (Record ('(y, b) ': xs)) a where
  getField (Cons _ _ r) = getField @x r

r :: Record '[ '("name", String) ]
r = Cons Proxy "R" Nil

x = getField @"name" r

Environment

  • GHC version used (if appropriate):

didn't compile

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information