Skip to content

Invalid syntax allowed for top-level type families

Summary

For top-level type families, it is currently possible to name their output without specifying a subsequent functional dependency:

{-# LANGUAGE TypeFamilyDependencies #-}

type family Arb a = r

But for associated type families, it is not

{-# LANGUAGE TypeFamilyDependencies #-}

class F a where
  type family Arb a = r  -- ^ illegal syntax

I think the first case shouldn't be allowed.

This may be fixed by some changes to Parser/Postprocess.hs in the function mkfamdecl.

Steps to reproduce

Copy and paste above code.

Expected behavior

The first example for open type families should cause a syntax error.

Environment

  • GHC version used: 9.8.2

Optional:

  • Operating System: Ubuntu 23.04
  • System Architecture: ?
Edited by sheaf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information