Skip to content

Regression around overloaded literals and type applications

The new eager instantiation approach (adopted as a part of Quick Look) does not treat overloaded literals as "heads". This causes trouble when using them with type applications, which can be useful when using -XRebindableSyntax. Specifically, the following module compiles with released GHCs:

{-# LANGUAGE RebindableSyntax, RankNTypes, TypeApplications, OverloadedStrings,
             OverloadedLists, TypeFamilies #-}

module Bug where

import qualified Prelude as P
import qualified GHC.Exts as P
import Data.List.NonEmpty ( NonEmpty )

fromInteger :: P.Integer -> forall a. P.Num a => a
fromInteger n = P.fromInteger n

shouldBeAnInt = 3 @P.Int

newtype RevString = RevString P.String
  deriving P.Show

instance P.IsString RevString where
  fromString str = RevString (P.reverse str)

fromString :: P.String -> forall a. P.IsString a => a
fromString str = P.fromString str

shouldBeARevString = "hello" @RevString

fromListN :: P.Int -> [elt] -> forall list. (P.IsList list, elt ~ P.Item list) => list
fromListN n l = P.fromListN n l

shouldBeANonEmpty = ['x', 'y', 'z'] @(NonEmpty P.Char)

All three shouldBe definitions are rejected with HEAD. But accepted by 8.x

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