Commit 8168b42a authored by Vladislav Zavialov's avatar Vladislav Zavialov

Whitespace-sensitive bang patterns (#1087, #17162)

This patch implements a part of GHC Proposal #229 that covers five
operators:

* the bang operator (!)
* the tilde operator (~)
* the at operator (@)
* the dollar operator ($)
* the double dollar operator ($$)

Based on surrounding whitespace, these operators are disambiguated into
bang patterns, lazy patterns, strictness annotations, type
applications, splices, and typed splices.

This patch doesn't cover the (-) operator or the -Woperator-whitespace
warning, which are left as future work.
parent 5a08f7d4
......@@ -2308,9 +2308,8 @@ type instance XXSplice (GhcPass _) = NoExtCon
-- type captures explicitly how it was originally written, for use in the pretty
-- printer.
data SpliceDecoration
= HasParens -- ^ $( splice ) or $$( splice )
| HasDollar -- ^ $splice or $$splice
| NoParens -- ^ bare splice
= DollarSplice -- ^ $splice or $$splice
| BareSplice -- ^ bare splice
deriving (Data, Eq, Show)
instance Outputable SpliceDecoration where
......@@ -2452,12 +2451,12 @@ instance (OutputableBndrId p) => Outputable (HsSplice (GhcPass p)) where
pprPendingSplice :: (OutputableBndrId p)
=> SplicePointName -> LHsExpr (GhcPass p) -> SDoc
pprPendingSplice n e = angleBrackets (ppr n <> comma <+> ppr e)
pprPendingSplice n e = angleBrackets (ppr n <> comma <+> ppr (stripParensHsExpr e))
pprSpliceDecl :: (OutputableBndrId p)
=> HsSplice (GhcPass p) -> SpliceExplicitFlag -> SDoc
pprSpliceDecl e@HsQuasiQuote{} _ = pprSplice e
pprSpliceDecl e ExplicitSplice = text "$(" <> ppr_splice_decl e <> text ")"
pprSpliceDecl e ExplicitSplice = text "$" <> ppr_splice_decl e
pprSpliceDecl e ImplicitSplice = ppr_splice_decl e
ppr_splice_decl :: (OutputableBndrId p)
......@@ -2466,17 +2465,13 @@ ppr_splice_decl (HsUntypedSplice _ _ n e) = ppr_splice empty n e empty
ppr_splice_decl e = pprSplice e
pprSplice :: (OutputableBndrId p) => HsSplice (GhcPass p) -> SDoc
pprSplice (HsTypedSplice _ HasParens n e)
= ppr_splice (text "$$(") n e (text ")")
pprSplice (HsTypedSplice _ HasDollar n e)
pprSplice (HsTypedSplice _ DollarSplice n e)
= ppr_splice (text "$$") n e empty
pprSplice (HsTypedSplice _ NoParens n e)
= ppr_splice empty n e empty
pprSplice (HsUntypedSplice _ HasParens n e)
= ppr_splice (text "$(") n e (text ")")
pprSplice (HsUntypedSplice _ HasDollar n e)
pprSplice (HsTypedSplice _ BareSplice _ _ )
= panic "Bare typed splice" -- impossible
pprSplice (HsUntypedSplice _ DollarSplice n e)
= ppr_splice (text "$") n e empty
pprSplice (HsUntypedSplice _ NoParens n e)
pprSplice (HsUntypedSplice _ BareSplice n e)
= ppr_splice empty n e empty
pprSplice (HsQuasiQuote _ n q _ s) = ppr_quasi n q s
pprSplice (HsSpliced _ _ thing) = ppr thing
......
......@@ -4137,7 +4137,8 @@ wWarningFlagsDeps = [
flagSpec "unrecognised-warning-flags" Opt_WarnUnrecognisedWarningFlags,
flagSpec "star-binder" Opt_WarnStarBinder,
flagSpec "star-is-type" Opt_WarnStarIsType,
flagSpec "missing-space-after-bang" Opt_WarnSpaceAfterBang,
depFlagSpec "missing-space-after-bang" Opt_WarnSpaceAfterBang
"bang patterns can no longer be written with a space",
flagSpec "partial-fields" Opt_WarnPartialFields,
flagSpec "prepositive-qualified-module"
Opt_WarnPrepositiveQualifiedModule,
......
......@@ -258,9 +258,9 @@ data AnnKeywordId
| AnnOpenEQ -- ^ '[|'
| AnnOpenEQU -- ^ '[|', unicode variant
| AnnOpenP -- ^ '('
| AnnOpenPE -- ^ '$('
| AnnOpenPTE -- ^ '$$('
| AnnOpenS -- ^ '['
| AnnDollar -- ^ prefix '$' -- TemplateHaskell
| AnnDollarDollar -- ^ prefix '$$' -- TemplateHaskell
| AnnPackageName
| AnnPattern
| AnnProc
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -260,6 +260,27 @@ eqTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "~") eqTyConK
eqDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "Eq#") eqDataConKey eqDataCon
eqSCSelIdName = mkWiredInIdName gHC_TYPES (fsLit "eq_sel") eqSCSelIdKey eqSCSelId
{- Note [eqTyCon (~) is built-in syntax]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The (~) type operator used in equality constraints (a~b) is considered built-in
syntax. This has a few consequences:
* The user is not allowed to define their own type constructors with this name:
ghci> class a ~ b
<interactive>:1:1: error: Illegal binding of built-in syntax: ~
* Writing (a ~ b) does not require enabling -XTypeOperators. It does, however,
require -XGADTs or -XTypeFamilies.
* The (~) type operator is always in scope. It doesn't need to be be imported,
and it cannot be hidden.
* We have a bunch of special cases in the compiler to arrange all of the above.
There's no particular reason for (~) to be special, but fixing this would be a
breaking change.
-}
eqTyCon_RDR :: RdrName
eqTyCon_RDR = nameRdrName eqTyConName
......
......@@ -1555,7 +1555,13 @@ dataTcOccs rdr_name
= [rdr_name]
where
occ = rdrNameOcc rdr_name
rdr_name_tc = setRdrNameSpace rdr_name tcName
rdr_name_tc =
case rdr_name of
-- The (~) type operator is always in scope, so we need a special case
-- for it here, or else :info (~) fails in GHCi.
-- See Note [eqTyCon (~) is built-in syntax]
Unqual occ | occNameFS occ == fsLit "~" -> eqTyCon_RDR
_ -> setRdrNameSpace rdr_name tcName
{-
Note [dataTcOccs and Exact Names]
......
......@@ -753,7 +753,7 @@ traceSplice (SpliceInfo { spliceDescription = sd, spliceSource = mb_src
spliceDebugDoc loc
= let code = case mb_src of
Nothing -> ending
Just e -> nest 2 (ppr e) : ending
Just e -> nest 2 (ppr (stripParensHsExpr e)) : ending
ending = [ text "======>", nest 2 gen ]
in hang (ppr loc <> colon <+> text "Splicing" <+> text sd)
2 (sep code)
......
......@@ -49,6 +49,45 @@ Lexical syntax
reserving ``forall`` as a keyword has significance. For instance, GHC will
not parse the type signature ``foo :: forall x``.
- The ``(!)`` operator, when written in prefix form (preceded by whitespace
and not followed by whitespace, as in ``f !x = ...``), is interpreted as a
bang pattern, contrary to the Haskell Report, which prescribes to treat ``!``
as an operator regardless of surrounding whitespace. Note that this does not
imply that GHC always enables :extension:`BangPatterns`. Without the
extension, GHC will issue a parse error on ``f !x``, asking to enable the
extension.
- Irrefutable patterns must be written in prefix form::
f ~a ~b = ... -- accepted by both GHC and the Haskell Report
f ~ a ~ b = ... -- accepted by the Haskell Report but not GHC
When written in non-prefix form, ``(~)`` is treated by GHC as a regular
infix operator.
See `GHC Proposal #229 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0229-whitespace-bang-patterns.rst>`__
for the precise rules.
- Strictness annotations in data declarations must be written in prefix form::
data T = MkT !Int -- accepted by both GHC and the Haskell Report
data T = MkT ! Int -- accepted by the Haskell Report but not GHC
See `GHC Proposal #229 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0229-whitespace-bang-patterns.rst>`__
for the precise rules.
- As-patterns must not be surrounded by whitespace::
f p@(x, y, z) = ... -- accepted by both GHC and the Haskell Report
f p @ (x, y, z) = ... -- accepted by the Haskell Report but not GHC
When surrounded by whitespace, ``(@)`` is treated by GHC as a regular infix
operator.
See `GHC Proposal #229 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0229-whitespace-bang-patterns.rst>`__
for the precise rules.
.. _infelicities-syntax:
Context-free syntax
......
......@@ -13108,10 +13108,9 @@ enable the quotation subset of Template Haskell (i.e. without splice syntax).
The :extension:`TemplateHaskellQuotes` extension is considered safe under
:ref:`safe-haskell` while :extension:`TemplateHaskell` is not.
- A splice is written ``$x``, where ``x`` is an identifier, or
``$(...)``, where the "..." is an arbitrary expression. There must be
no space between the "$" and the identifier or parenthesis. This use
of "$" overrides its meaning as an infix operator, just as "M.x"
- A splice is written ``$x``, where ``x`` is an arbitrary expression.
There must be no space between the "$" and the expression.
This use of "$" overrides its meaning as an infix operator, just as "M.x"
overrides the meaning of "." as an infix operator. If you want the
infix operator, put spaces around it.
......@@ -13147,9 +13146,8 @@ The :extension:`TemplateHaskellQuotes` extension is considered safe under
See :ref:`pts-where` for using partial type signatures in quotations.
- A *typed* expression splice is written ``$$x``, where ``x`` is an
identifier, or ``$$(...)``, where the "..." is an arbitrary
expression.
- A *typed* expression splice is written ``$$x``, where ``x`` is
is an arbitrary expression.
A typed expression splice can occur in place of an expression; the
spliced expression must have type ``Q (TExp a)``
......@@ -14323,12 +14321,15 @@ Note the following points:
f !x = 3
Is this a definition of the infix function "``(!)``", or of the "``f``"
with a bang pattern? GHC resolves this ambiguity in favour of the
latter. If you want to define ``(!)`` with bang-patterns enabled, you
have to do so using prefix notation: ::
Is this a definition of the infix function "``(!)``", or of the "``f``" with
a bang pattern? GHC resolves this ambiguity by looking at the surrounding
whitespace: ::
(!) f x = 3
a ! b = ... -- infix operator
a !b = ... -- bang pattern
See `GHC Proposal #229 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0229-whitespace-bang-patterns.rst>`__
for the precise rules.
.. _strict-data:
......@@ -14359,6 +14360,13 @@ we interpret it as if they had written ::
The extension only affects definitions in this module.
The ``~`` annotation must be written in prefix form::
data T = MkT ~Int -- valid
data T = MkT ~ Int -- invalid
See `GHC Proposal #229 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0229-whitespace-bang-patterns.rst>`__
for the precise rules.
.. _strict:
......@@ -14393,7 +14401,7 @@ optionally had by adding ``!`` in front of a variable.
Adding ``~`` in front of ``x`` gives the regular lazy behavior.
Turning patterns into irrefutable ones requires ``~(~p)`` or ``(~ ~p)`` when ``Strict`` is enabled.
Turning patterns into irrefutable ones requires ``~(~p)`` when ``Strict`` is enabled.
......
......@@ -46,7 +46,6 @@ generally likely to indicate bugs in your program. These are:
* :ghc-flag:`-Winaccessible-code`
* :ghc-flag:`-Wstar-is-type`
* :ghc-flag:`-Wstar-binder`
* :ghc-flag:`-Wspace-after-bang`
The following flags are simple ways to select standard "packages" of warnings:
......@@ -1280,12 +1279,6 @@ of ``-W(no-)*``.
per-module basis with :ghc-flag:`-Wno-simplifiable-class-constraints
<-Wsimplifiable-class-constraints>`.
.. ghc-flag:: -Wspace-after-bang
:shortdesc: warn for missing space before the second argument
of an infix definition of ``(!)`` when
:extension:`BangPatterns` are not enabled
:type: dynamic
:reverse: -Wno-missing-space-after-bang
.. ghc-flag:: -Wtabs
:shortdesc: warn if there are tabs in the source file
:type: dynamic
......
Subproject commit a6cbac8fd8c69d85fddfde0a2686607e1ae22947
Subproject commit c9fe4e92b88cd052d5fea8b713569d16c05ebf0e
......@@ -14,7 +14,7 @@
((Test10268.hs:5:1-17,AnnEqual), [Test10268.hs:5:4]),
((Test10268.hs:5:1-17,AnnFunId), [Test10268.hs:5:1-2]),
((Test10268.hs:5:1-17,AnnSemi), [Test10268.hs:7:1]),
((Test10268.hs:5:6-17,AnnThIdSplice), [Test10268.hs:5:6-17]),
((Test10268.hs:5:6-17,AnnDollar), [Test10268.hs:5:6]),
((Test10268.hs:7:1-27,AnnDcolon), [Test10268.hs:7:6-7]),
((Test10268.hs:7:1-27,AnnSemi), [Test10268.hs:8:1]),
((Test10268.hs:7:9,AnnRarrow), [Test10268.hs:7:11-12]),
......
......@@ -29,8 +29,9 @@
((Test10276.hs:(10,13)-(11,74),AnnClose), [Test10276.hs:11:72-74]),
((Test10276.hs:(10,13)-(11,74),AnnOpen), [Test10276.hs:10:13-15]),
((Test10276.hs:(10,16)-(11,71),AnnVal), [Test10276.hs:10:20]),
((Test10276.hs:10:31-42,AnnCloseP), [Test10276.hs:10:42]),
((Test10276.hs:10:31-42,AnnOpenPTE), [Test10276.hs:10:31-33]),
((Test10276.hs:10:31-42,AnnDollarDollar), [Test10276.hs:10:31-32]),
((Test10276.hs:10:33-42,AnnCloseP), [Test10276.hs:10:42]),
((Test10276.hs:10:33-42,AnnOpenP), [Test10276.hs:10:33]),
((Test10276.hs:11:25-71,AnnCloseP), [Test10276.hs:11:71]),
((Test10276.hs:11:25-71,AnnOpenP), [Test10276.hs:11:25]),
((Test10276.hs:11:26-36,AnnCloseP), [Test10276.hs:11:36]),
......@@ -50,8 +51,9 @@
((Test10276.hs:(14,13)-(15,74),AnnClose), [Test10276.hs:15:72-74]),
((Test10276.hs:(14,13)-(15,74),AnnOpenE), [Test10276.hs:14:13-16]),
((Test10276.hs:(14,17)-(15,71),AnnVal), [Test10276.hs:14:21]),
((Test10276.hs:14:32-43,AnnCloseP), [Test10276.hs:14:43]),
((Test10276.hs:14:32-43,AnnOpenPTE), [Test10276.hs:14:32-34]),
((Test10276.hs:14:32-43,AnnDollarDollar), [Test10276.hs:14:32-33]),
((Test10276.hs:14:34-43,AnnCloseP), [Test10276.hs:14:43]),
((Test10276.hs:14:34-43,AnnOpenP), [Test10276.hs:14:34]),
((Test10276.hs:15:25-71,AnnCloseP), [Test10276.hs:15:71]),
((Test10276.hs:15:25-71,AnnOpenP), [Test10276.hs:15:25]),
((Test10276.hs:15:26-36,AnnCloseP), [Test10276.hs:15:36]),
......
......@@ -16,12 +16,12 @@
((Test10358.hs:(4,1)-(8,6),AnnSemi), [Test10358.hs:9:1]),
((Test10358.hs:(5,3)-(8,6),AnnIn), [Test10358.hs:8:3-4]),
((Test10358.hs:(5,3)-(8,6),AnnLet), [Test10358.hs:5:3-5]),
((Test10358.hs:5:7-16,AnnBang), [Test10358.hs:5:7]),
((Test10358.hs:5:7-10,AnnBang), [Test10358.hs:5:7]),
((Test10358.hs:5:7-16,AnnEqual), [Test10358.hs:5:12]),
((Test10358.hs:5:7-16,AnnFunId), [Test10358.hs:5:8-10]),
((Test10358.hs:5:7-16,AnnSemi), [Test10358.hs:5:17]),
((Test10358.hs:5:14-16,AnnVal), [Test10358.hs:5:15]),
((Test10358.hs:5:19-32,AnnBang), [Test10358.hs:5:19]),
((Test10358.hs:5:19-22,AnnBang), [Test10358.hs:5:19]),
((Test10358.hs:5:19-32,AnnEqual), [Test10358.hs:5:24]),
((Test10358.hs:5:19-32,AnnFunId), [Test10358.hs:5:20-22]),
((Test10358.hs:5:19-32,AnnSemi), [Test10358.hs:6:7]),
......
......@@ -82,12 +82,13 @@
((Test10399.hs:20:1-25,AnnCloseQ), [Test10399.hs:20:24-25]),
((Test10399.hs:20:1-25,AnnOpen), [Test10399.hs:20:1-3]),
((Test10399.hs:20:1-25,AnnSemi), [Test10399.hs:22:1]),
((Test10399.hs:20:20-22,AnnThIdSplice), [Test10399.hs:20:20-22]),
((Test10399.hs:20:20-22,AnnDollar), [Test10399.hs:20:20]),
((Test10399.hs:22:1-21,AnnEqual), [Test10399.hs:22:19]),
((Test10399.hs:22:1-21,AnnFunId), [Test10399.hs:22:1-3]),
((Test10399.hs:22:1-21,AnnSemi), [Test10399.hs:23:1]),
((Test10399.hs:22:5-17,AnnCloseP), [Test10399.hs:22:17]),
((Test10399.hs:22:5-17,AnnOpenPE), [Test10399.hs:22:5-6]),
((Test10399.hs:22:5-17,AnnDollar), [Test10399.hs:22:5]),
((Test10399.hs:22:6-17,AnnCloseP), [Test10399.hs:22:17]),
((Test10399.hs:22:6-17,AnnOpenP), [Test10399.hs:22:6]),
((Test10399.hs:22:8-15,AnnCloseQ), [Test10399.hs:22:14-15]),
((Test10399.hs:22:8-15,AnnOpen), [Test10399.hs:22:8-10]),
((<no location info>,AnnEofPos), [Test10399.hs:23:1])
......
mod69.hs:3:7: error:
Pattern syntax in expression context: x@1
Did you mean to enable TypeApplications?
@-pattern in expression context: x@1
Type application syntax requires a space before '@'
mod70.hs:3:9: error: Pattern syntax in expression context: ~1
mod70.hs:3:9: error:
Lazy pattern in expression context: ~1
Did you mean to add a space after the '~'?
T11103.hs:13:3: error:
T11103.hs:13:2: error:
Ambiguous occurrence ‘Main.foo’
It could refer to either the field ‘foo’,
defined at T11103.hs:11:16
or the field ‘foo’, defined at T11103.hs:10:16
It could refer to
either the field ‘foo’, defined at T11103.hs:11:16
or the field ‘foo’, defined at T11103.hs:10:16
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
module Proposal229f_instances where
import GHC.Exts
import Data.String
import Language.Haskell.TH
import Language.Haskell.TH.Syntax
instance IsList (Q (TExp String)) where
type Item (Q (TExp String)) = Char
fromList = liftTyped
toList = undefined
instance IsList (Q Exp) where
type Item (Q Exp) = Char
fromList = lift
toList = undefined
instance IsString (Q (TExp String)) where
fromString = liftTyped
instance IsString (Q Exp) where
fromString = lift
{-# LANGUAGE BangPatterns #-}
module T1087 where
prefix_1 = let at a !b = False in at 1 2
prefix_2 = let (.!.) a !b = False in 1 .!. 2
infix_tilde_1 = let a `at` ~b = False in at 1 2
infix_tilde_2 = let a .!. ~b = False in 1 .!. 2
infix_tilde_3 = let ~a .!. b = False in 1 .!. 2
infix_bang_1 = let a .!. !b = False in 1 .!. 2
infix_bang_2 = let a `at` !b = False in at 1 2
infix_bang_3 = let !a .!. b = False in 1 .!. 2
T16619.hs:2:12: warning:
-Wmissing-space-after-bang is deprecated: bang patterns can no longer be written with a space
......@@ -145,3 +145,20 @@ test('T16339', normal, compile, [''])
test('T16619', req_th, multimod_compile, ['T16619', '-v0'])
test('T504', normal, compile, [''])
test('T515', literate, compile, ['-Wall'])
test('T1087', normal, compile, [''])
test('proposal-229a', normal, compile, [''])
test('proposal-229b', normal, compile, [''])
test('proposal-229d', normal, compile, [''])
test('proposal-229e', normal, compile, [''])
# We omit 'profasm' because it fails with:
# Cannot load -prof objects when GHC is built with -dynamic
# To fix this, either:
# (1) Use -fexternal-interpreter, or
# (2) Build the program twice: once with -dynamic, and then
# with -prof using -osuf to set a different object file suffix.
test('proposal-229f',
[ extra_files(['proposal-229f.hs', 'Proposal229f_instances.hs']),
omit_ways(['profasm', 'profthreaded'])
],
multimod_compile_and_run, ['proposal-229f.hs', ''])
{-# LANGUAGE BangPatterns #-}
module Proposal229a where
data T a b = a :! b
(!) :: x -> T a b -> (x, a, b)
~u ! !(!m :! !n) = (u, m, n)
module Proposal229b ((~), (@)) where
(~) :: a -> b -> (a, b)
x ~ y = (x, y)
(@) :: a -> b -> (a, b)
x @ y = (x, y)
r :: ((Bool, Bool), Bool)
r = True ~ False @ True
{-# LANGUAGE BangPatterns #-}
module Proposal229d ((!)) where
(!) :: a -> b -> (a, b)
x ! y = (x,y) -- parsed as an operator even with BangPatterns enabled
{-# LANGUAGE BangPatterns #-}
module Proposal229e ((!), f) where
(!) :: Maybe a -> a -> (a, a)
f :: a -> a
-- the preceding '}' is not from a comment,
-- so (!) is tight infix (therefore an operator)
Nothing{}!x = (x, x)
-- the following '{' opens a multi-line comment,
-- so (!) is loose infix (therefore an operator)
Just a !{-comment-}x = (a, x)
-- the preceding '}' is closing a multi-line comment,
-- so (!) is prefix (therefore a bang pattern)
f{-comment-}!x = x
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedLists #-}
import System.IO
import Proposal229f_instances
-- Testing that we can parse $[...] and $"..."
main = do
hPutStrLn stderr $['1','2','3']
hPutStrLn stderr $$['1','2','3']
hPutStrLn stderr $"123"
hPutStrLn stderr $$"123"
T14588.hs:3:19: error:
Illegal bang-pattern (use BangPatterns):
! x
!x
T16270.hs:2:12: warning:
-Werror=missing-space-after-bang is deprecated: bang patterns can no longer be written with a space
T16270.hs:7:1: warning: [-Wtabs (in -Wdefault)]
Tab character found here, and in five further locations.
Please use spaces instead.
......@@ -46,10 +49,9 @@ T16270.hs:23:10: error:
Perhaps you intended to use GADTs or a similar language
extension to enable syntax: data T where
T16270.hs:25:12: error: [-Wmissing-space-after-bang (in -Wdefault), -Werror=missing-space-after-bang]
Did you forget to enable BangPatterns?
If you mean to bind (!) then perhaps you want
to add a space after the bang for clarity.
T16270.hs:25:12: error:
Illegal bang-pattern (use BangPatterns):
!i
T16270.hs:27:9: error:
Multi-way if-expressions need MultiWayIf turned on
......@@ -57,13 +59,13 @@ T16270.hs:27:9: error:
T16270.hs:29:9: error:
Multi-way if-expressions need MultiWayIf turned on
T16270.hs:32:6: Illegal lambda-case (use LambdaCase)
T16270.hs:32:6: error: Illegal lambda-case (use LambdaCase)
T16270.hs:35:5:
T16270.hs:35:5: error:
Use NumericUnderscores to allow underscores in integer literals
T16270.hs:37:5:
primitive string literal must contain only characters <= '/xFF'
T16270.hs:37:5: error:
primitive string literal must contain only characters <= '\xFF'
T16270.hs:43:1: error:
parse error (possibly incorrect indentation or mismatched brackets)
-- {-# LANGUAGE NoBangPatterns #-}
module T17162 where
charIsRepresentable :: TextEncoding -> Char -> IO Bool
charIsRepresentable !enc c =
withCString enc [c]
(\cstr -> do str <- peekCString enc cstr
case str of
[ch] | ch == c -> pure True
_ -> pure False)
`catch`
\(_ :: IOException) -> pure False
T17162.hs:6:21: error:
Illegal bang-pattern (use BangPatterns):
!enc
T3811b.hs:4:14: error:
Cannot parse data constructor in a data/newtype declaration:
! B
!B
T3811c.hs:6:11: error:
Strictness annotation applied to a compound type.
Did you mean to add parentheses?
!(Show D)
T3811c.hs:6:10: error:
Illegal class instance: ‘!Show D’
Class instances must be of the form
context => C ty_1 ... ty_n
where ‘C’ is a class
T3811f.hs:4:8: error:
Strictness annotation applied to a compound type.
Did you mean to add parentheses?
!(Foo a)
T3811f.hs:4:7: error:
Malformed head of type or class declaration: !Foo a
......@@ -161,3 +161,5 @@ test('patFail006', normal, compile_fail, [''])
test('patFail007', normal, compile_fail, [''])
test('patFail008', normal, compile_fail, [''])
test('patFail009', normal, compile_fail, [''])
test('T17162', normal, compile_fail, [''])
test('proposal-229c', normal, compile_fail, [''])
{-# LANGUAGE NoBangPatterns #-}
module Proposal229c (f) where
-- should recommend to enable BangPatterns instead of parsing as an infix operator
f !x = x
proposal-229c.hs:6:3: error:
Illegal bang-pattern (use BangPatterns):
!x
strictnessDataCon_A.hs:1:27: error:
Strictness annotation cannot appear in this position.
Operator applied to too few arguments: !
[1 of 2] Compiling Splices ( Splices.hs, Splices.o )
[2 of 2] Compiling SplicesUsed ( SplicesUsed.hs, SplicesUsed.o )
SplicesUsed.hs:7:16: warning: [-Wpartial-type-signatures (in -Wdefault)]
SplicesUsed.hs:7:15: warning: [-Wpartial-type-signatures (in -Wdefault)]
• Found type wildcard ‘_’ standing for ‘Maybe Bool’
• In the type ‘_’
In the type signature: maybeBool :: (_)
SplicesUsed.hs:8:15: warning: [-Wpartial-type-signatures (in -Wdefault)]
SplicesUsed.hs:8:14: warning: [-Wpartial-type-signatures (in -Wdefault)]
• Found type wildcard ‘_a’ standing for ‘_’
Where: ‘_’ is a rigid type variable bound by
the inferred type of <expression> :: _ -> _
at SplicesUsed.hs:8:15-22
at SplicesUsed.hs:8:14-23
• In an expression type signature: _a -> _a
In the expression: id :: _a -> _a
In the expression: (id :: _a -> _a) (Just True :: Maybe _)
• Relevant bindings include