ndmitchell / hlint

Haskell source code suggestions
Other
1.47k stars 196 forks source link

HLint Parse error #1329

Closed ymir-0 closed 2 years ago

ymir-0 commented 2 years ago

Hello,

I write this Haskell code in Sample.hs file :

{-# LANGUAGE GADTs #-}

-- GADT : schema field

data SchemaField schemaField where
  SchemaField :: (Eq fieldType, Show fieldType) => {
    name :: String,
    fieldType :: fieldType,
    nullable :: Bool
  } -> SchemaField (String,fieldType,Bool)

-- concrete schema field
instance Show (SchemaField schemaField) where
  show (SchemaField name fieldType nullable) =
    "SchemaField " ++ name ++ " " ++ show fieldType ++ " " ++ show nullable
data FieldType = StringType deriving (Show,Eq)
schemaFieldName = SchemaField "name" StringType False

-- run test
main :: IO ()
main = putStrLn (show schemaFieldName)

And hlint raise an error :

gitpod /tmp $ hlint Sample.hs
Sample.hs:6:52: Error: Parse error
Found:
    data SchemaField schemaField where
  >   SchemaField :: (Eq fieldType, Show fieldType) => {
        name :: String,
        fieldType :: fieldType,

1 hint

But GHC compiler has no problem

gitpod /tmp $ ghc Sample.hs
[1 of 1] Compiling Main             ( Sample.hs, Sample.o ) [flags changed]
Linking Sample ...
gitpod /tmp $ ./Sample 
SchemaField name StringType False
ymir-0 commented 2 years ago

I used an old Hlint version :

gitpod /tmp $ hlint --version
HLint v2.1.11, (C) Neil Mitchell 2006-2018

But the last one, the issue is gone :

gitpod /tmp $ hlint --version
HLint v3.2.7, (C) Neil Mitchell 2006-2021

I do not know if version 2.1.11 is still maintained

ndmitchell commented 2 years ago

Only the latest version is still maintained - what you wrote was probably not legal when the corresponding GHC was released. I suggest you upgrade.

ymir-0 commented 2 years ago

I upgraded to last HLint version, problem is gone. Thank you