@@ -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