{-# LANGUAGE CPP #-}
{-# LANGUAGE ImplicitParams #-}

module Language.PureScript.Crash where

import Prelude.Compat

import qualified GHC.Stack

-- | A compatibility wrapper for the @GHC.Stack.HasCallStack@ constraint.
#if __GLASGOW_HASKELL__ >= 800
type HasCallStack = GHC.Stack.HasCallStack
#elif MIN_VERSION_GLASGOW_HASKELL(7,10,2,0)
type HasCallStack = (?callStack :: GHC.Stack.CallStack)
#else
import GHC.Exts (Constraint)
-- CallStack wasn't present in GHC 7.10.1
type HasCallStack = (() :: Constraint)
#endif

-- | Exit with an error message and a crash report link.
internalError :: HasCallStack => String -> a
internalError :: String -> a
internalError =
  String -> a
forall a. HasCallStack => String -> a
error
  (String -> a) -> (String -> String) -> String -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
"An internal error occurred during compilation: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
  (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\nPlease report this at https://github.com/purescript/purescript/issues")