Built-in Natural literals in Core
authorSylvain Henry <hsyl20@gmail.com>
Fri, 15 Jun 2018 20:23:53 +0000 (16:23 -0400)
committerBen Gamari <ben@smart-cactus.org>
Fri, 15 Jun 2018 20:23:54 +0000 (16:23 -0400)
commitfe770c211631e7b4c9b0b1e88ef9b6046c6585ef
treee6a061a92d8d0d71d40c699982ee471627d816e0
parent42f3b53b5bc4674e41f16de08094821fe1aaec00
Built-in Natural literals in Core

Add support for built-in Natural literals in Core.

- Replace MachInt,MachWord, LitInteger, etc. with a single LitNumber
  constructor with a LitNumType field
- Support built-in Natural literals
- Add desugar warning for negative literals
- Move Maybe(..) from GHC.Base to GHC.Maybe for module dependency
  reasons

This patch introduces only a few rules for Natural literals (compared
to Integer's rules). Factorization of the built-in rules for numeric
literals will be done in another patch as this one is already big to
review.

Test Plan:
  validate
  test build with integer-simple

Reviewers: hvr, bgamari, goldfire, Bodigrim, simonmar

Reviewed By: bgamari

Subscribers: phadej, simonpj, RyanGlScott, carter, hsyl20, rwbarton,
thomie

GHC Trac Issues: #14170, #14465

Differential Revision: https://phabricator.haskell.org/D4212
80 files changed:
compiler/basicTypes/Literal.hs
compiler/codeGen/StgCmmCon.hs
compiler/codeGen/StgCmmUtils.hs
compiler/coreSyn/CorePrep.hs
compiler/coreSyn/CoreUnfold.hs
compiler/coreSyn/CoreUtils.hs
compiler/coreSyn/MkCore.hs
compiler/deSugar/MatchLit.hs
compiler/ghci/ByteCodeAsm.hs
compiler/ghci/ByteCodeGen.hs
compiler/iface/TcIface.hs
compiler/main/TidyPgm.hs
compiler/prelude/PrelNames.hs
compiler/prelude/PrelRules.hs
compiler/prelude/TysWiredIn.hs
compiler/simplStg/UnariseStg.hs
compiler/stgSyn/CoreToStg.hs
libraries/base/Data/Bits.hs
libraries/base/Data/Data.hs
libraries/base/GHC/Arr.hs
libraries/base/GHC/Base.hs
libraries/base/GHC/Base.hs-boot
libraries/base/GHC/Enum.hs
libraries/base/GHC/Err.hs
libraries/base/GHC/Exception.hs
libraries/base/GHC/Exception.hs-boot
libraries/base/GHC/Exception/Type.hs [new file with mode: 0644]
libraries/base/GHC/Exception/Type.hs-boot [new file with mode: 0644]
libraries/base/GHC/Int.hs
libraries/base/GHC/Maybe.hs [new file with mode: 0644]
libraries/base/GHC/Natural.hs
libraries/base/GHC/Num.hs
libraries/base/GHC/Read.hs
libraries/base/GHC/Real.hs
libraries/base/GHC/Show.hs
libraries/base/GHC/Stack/Types.hs
libraries/base/GHC/Word.hs
libraries/base/Unsafe/Coerce.hs
libraries/base/base.cabal
libraries/template-haskell/Language/Haskell/TH/Syntax.hs
testsuite/tests/ado/T13242a.stderr
testsuite/tests/generics/GenDerivOutput.stderr
testsuite/tests/generics/GenDerivOutput1_0.stderr
testsuite/tests/generics/GenDerivOutput1_1.stderr
testsuite/tests/generics/T10604/T10604_deriving.stderr
testsuite/tests/ghci.debugger/scripts/break006.stderr
testsuite/tests/ghci.debugger/scripts/print019.stderr
testsuite/tests/ghci/scripts/Defer02.stderr
testsuite/tests/ghci/scripts/T10963.stderr
testsuite/tests/ghci/scripts/T4175.stdout
testsuite/tests/indexed-types/should_fail/T12522a.stderr
testsuite/tests/numeric/should_compile/Makefile
testsuite/tests/numeric/should_compile/T14170.hs [new file with mode: 0644]
testsuite/tests/numeric/should_compile/T14170.stdout [new file with mode: 0644]
testsuite/tests/numeric/should_compile/T14465.hs [new file with mode: 0644]
testsuite/tests/numeric/should_compile/T14465.stderr [new file with mode: 0644]
testsuite/tests/numeric/should_compile/T14465.stdout [new file with mode: 0644]
testsuite/tests/numeric/should_compile/all.T
testsuite/tests/overloadedlists/should_fail/overloadedlistsfail01.stderr
testsuite/tests/partial-sigs/should_fail/T10999.stderr
testsuite/tests/plugins/plugins09.stdout
testsuite/tests/plugins/plugins11.stdout
testsuite/tests/simplCore/should_compile/spec-inline.stderr
testsuite/tests/th/ClosedFam1TH.stderr
testsuite/tests/th/T14060.stdout
testsuite/tests/th/T4135.stderr
testsuite/tests/th/T5037.stderr
testsuite/tests/th/T8953.stderr
testsuite/tests/th/TH_RichKinds2.stderr
testsuite/tests/th/TH_reifyDecl2.stderr
testsuite/tests/th/TH_repGuard.stderr
testsuite/tests/typecheck/should_compile/T14273.stderr
testsuite/tests/typecheck/should_compile/holes2.stderr
testsuite/tests/typecheck/should_compile/valid_hole_fits.stderr
testsuite/tests/typecheck/should_fail/T14884.stderr
testsuite/tests/typecheck/should_fail/T5095.stderr
testsuite/tests/typecheck/should_fail/tcfail008.stderr
testsuite/tests/typecheck/should_fail/tcfail072.stderr
testsuite/tests/typecheck/should_fail/tcfail133.stderr
testsuite/tests/typecheck/should_fail/tcfail182.stderr