Implement support for user-defined type errors.
authorIavor S. Diatchki <iavor.diatchki@gmail.com>
Mon, 16 Nov 2015 16:08:14 +0000 (17:08 +0100)
committerBen Gamari <ben@smart-cactus.org>
Mon, 16 Nov 2015 20:59:47 +0000 (21:59 +0100)
commit2d1a563bf25a4e402088feb1cdcac3d7bc50c6d3
tree1c3e490f397ba93bd3f7b82703aaad783b54279e
parente2d9821bf611da389df7ab8826b957d37351c29d
Implement support for user-defined type errors.

Implements Lennart's idea from the Haskell Symposium.
Users may use the special type function `TypeError`, which is
similar to `error` at the value level.

See Trac ticket https://ghc.haskell.org/trac/ghc/ticket/9637, and wiki
page https://ghc.haskell.org/trac/ghc/wiki/CustomTypeErros

Test Plan: Included testcases

Reviewers: simonpj, austin, hvr, goldfire, bgamari

Reviewed By: goldfire, bgamari

Subscribers: adamgundry, thomie

Differential Revision: https://phabricator.haskell.org/D1236

GHC Trac Issues: #9637
14 files changed:
compiler/prelude/PrelNames.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcValidity.hs
compiler/types/Type.hs
compiler/types/TypeRep.hs
libraries/base/GHC/TypeLits.hs
testsuite/tests/typecheck/should_fail/CustomTypeErrors01.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/CustomTypeErrors01.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/CustomTypeErrors02.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/CustomTypeErrors02.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/CustomTypeErrors03.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/CustomTypeErrors03.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/all.T