haskell / happy

The Happy parser generator for Haskell
Other
276 stars 84 forks source link

GLR: generated file `*Data.hs` doesn't declare its OPTIONS and LANGUAGE pragmas #183

Open andreasabel opened 3 years ago

andreasabel commented 3 years ago

The GLR generated file *Data.hs doesn't declare its OPTIONS and LANGUAGE pragmas.

Suggestion: Emit the following in the preamble when generating this file:

{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}

{-# OPTIONS_GHC -Wno-unused-imports #-}
{-# OPTIONS_GHC -Wno-unused-matches #-}
{-# OPTIONS_GHC -Wno-missing-signatures #-}

Details

I am getting errors like:

    • Illegal instance declaration for ‘TreeDecode String’
        (All instance types must be of the form (T t1 ... tn)
         where T is not a synonym.
         Use TypeSynonymInstances if you want to disable this.)

    • Illegal instance declaration for ‘TreeDecode [AbsAlfa.Decl]’
        (All instance types must be of the form (T a1 ... an)
         where a1 ... an are *distinct type variables*,
         and each type variable appears at most once in the instance head.
         Use FlexibleInstances if you want to disable this.)

With -Wall I am getting warnings like:

ParTestData.hs:16:1: error: [-Wunused-imports, -Werror=unused-imports]
    The qualified import of ‘Data.Array’ is redundant
      except perhaps to import instances from ‘Data.Array’
    To import instances alone, use: import Data.Array()
   |
16 | import qualified Data.Array as Happy_Data_Array
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ParTestData.hs:17:1: error: [-Wunused-imports, -Werror=unused-imports]
    The qualified import of ‘Data.Bits’ is redundant
      except perhaps to import instances from ‘Data.Bits’
    To import instances alone, use: import Data.Bits()
   |
17 | import qualified Data.Bits as Bits
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ParTestData.hs:18:1: error: [-Wunused-imports, -Werror=unused-imports]
    The import of ‘Control.Applicative’ is redundant
      except perhaps to import instances from ‘Control.Applicative’
    To import instances alone, use: import Control.Applicative()
   |
18 | import Control.Applicative(Applicative(..))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ParTestData.hs:19:1: error: [-Wunused-imports, -Werror=unused-imports]
    The import of ‘Control.Monad’ is redundant
      except perhaps to import instances from ‘Control.Monad’
    To import instances alone, use: import Control.Monad()
   |
19 | import Control.Monad (ap)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^

templates/GLR_Base.hs:53:10: error: [-Wunused-matches, -Werror=unused-matches]
    Defined but not used: ‘i’

templates/GLR_Base.hs:68:1: error: [-Wmissing-signatures, -Werror=missing-signatures]
    Top-level binding with no type signature:
      cross_fn :: Monad m => [m (t -> b)] -> [m t] -> [m b]