haskell-suite / haskell-src-exts

Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer
Other
193 stars 94 forks source link

Error with data instance and type operators #402

Open ndmitchell opened 6 years ago

ndmitchell commented 6 years ago

From https://github.com/ndmitchell/hlint/issues/450 by @LeanderK:

{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs                  #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeInType #-}
module Test where

import           Data.Singletons.Prelude
import           Data.Singletons.TypeLits
import           Data.Type.Equality            ((:~:) (..), (:~~:) (..))

data instance Sing (z :: (a :~: b)) where
    SRefl :: Sing Refl

Gives a parse error on the :~:.

elaforge commented 6 years ago

This is probably the same thing, also a parse error with haskell-src-exts but not ghc:

{-# LANGUAGE DataKinds, TypeOperators #-}
import Data.Proxy (Proxy(..))
import qualified GHC.TypeLits as TypeLits

f :: Proxy n -> Proxy (n TypeLits.+ 1)
f Proxy = Proxy
LeanderK commented 6 years ago

I think here is another example

import           Data.Type.Equality            ((:~:) (..), (:~~:) (..))
mpickering commented 6 years ago

At least one problem is that kinds and types are still parsed differently in HSE but in GHC, they are parsed as the same thing. I'm not going to work on this any more for now.

AshleyYakeley commented 6 years ago

414 may fix this.