Skip to content

Commit 6277f69

Browse files
alexbiehlpaf31
authored andcommitted
Add HasCallStack to internalError (purescript#2608)
* Add HasCallStack to internalError * Update CONTRIBUTORS.md * Update CONTRIBUTORS.md * Update CONTRIBUTORS.md
1 parent 090f185 commit 6277f69

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ This file lists the contributors to the PureScript compiler project, and the ter
8989
- [@RyanGlScott](https://github.com/RyanGlScott) (Ryan Scott) My existing contributions and all future contributions until further notice are Copyright Ryan Scott, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
9090
- [@seungha-kim](https://github.com/seungha-kim) (Seungha Kim) My existing contributions and all future contributions until further notice are Copyright Seungha Kim, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
9191
- [@matthewleon](https://github.com/matthewleon) (Matthew Leon) My existing contributions and all future contributions until further notice are Copyright Matthew Leon, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
92+
- [@alexbiehl](https://github.com/alexbiehl) (Alexander Biehl) My existing contributions and all future contributions until further notice are Copyright Alexander Biehl, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
9293

9394
### Companies
9495

src/Language/PureScript/Crash.hs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
module Language.PureScript.Crash where
2-
3-
import Prelude.Compat
4-
5-
-- | Exit with an error message and a crash report link.
6-
internalError :: String -> a
7-
internalError =
8-
error
9-
. ("An internal error occurred during compilation: " ++)
10-
. (++ "\nPlease report this at https://github.com/purescript/purescript/issues")
11-
. show
1+
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE ImplicitParams #-}
3+
4+
module Language.PureScript.Crash where
5+
6+
import Prelude.Compat
7+
8+
import qualified GHC.Stack
9+
10+
-- | A compatibility wrapper for the @GHC.Stack.HasCallStack@ constraint.
11+
#if __GLASGOW_HASKELL__ >= 800
12+
type HasCallStack = GHC.Stack.HasCallStack
13+
#elif MIN_VERSION_GLASGOW_HASKELL(7,10,2,0)
14+
type HasCallStack = (?callStack :: GHC.Stack.CallStack)
15+
#else
16+
import GHC.Exts (Constraint)
17+
-- CallStack wasn't present in GHC 7.10.1
18+
type HasCallStack = (() :: Constraint)
19+
#endif
20+
21+
-- | Exit with an error message and a crash report link.
22+
internalError :: HasCallStack => String -> a
23+
internalError =
24+
error
25+
. ("An internal error occurred during compilation: " ++)
26+
. (++ "\nPlease report this at https://github.com/purescript/purescript/issues")
27+
. show

0 commit comments

Comments
 (0)