Panic module.
This commit is contained in:
@@ -48,6 +48,7 @@ library
|
|||||||
Functor
|
Functor
|
||||||
Semiring
|
Semiring
|
||||||
Bifunctor
|
Bifunctor
|
||||||
|
Panic
|
||||||
|
|
||||||
default-extensions:
|
default-extensions:
|
||||||
NoImplicitPrelude
|
NoImplicitPrelude
|
||||||
|
|||||||
+3
-5
@@ -18,10 +18,6 @@ import Control.Monad (Monad, return)
|
|||||||
import qualified Base as P
|
import qualified Base as P
|
||||||
import qualified Debug.Trace as T
|
import qualified Debug.Trace as T
|
||||||
|
|
||||||
{-# WARNING undefined "'undefined' remains in code" #-}
|
|
||||||
undefined :: a
|
|
||||||
undefined = P.undefined
|
|
||||||
|
|
||||||
{-# WARNING error "'error' remains in code" #-}
|
{-# WARNING error "'error' remains in code" #-}
|
||||||
error :: String -> a
|
error :: String -> a
|
||||||
error = P.error
|
error = P.error
|
||||||
@@ -46,6 +42,8 @@ traceM s = T.trace s (return ())
|
|||||||
traceIO :: String -> P.IO ()
|
traceIO :: String -> P.IO ()
|
||||||
traceIO = T.traceIO
|
traceIO = T.traceIO
|
||||||
|
|
||||||
{-# WARNING notImplemented "'notImplemented' remains in code" #-}
|
|
||||||
notImplemented :: a
|
notImplemented :: a
|
||||||
notImplemented = P.error "Not implemented"
|
notImplemented = P.error "Not implemented"
|
||||||
|
|
||||||
|
undefined :: a
|
||||||
|
undefined = P.undefined
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
module Panic (
|
||||||
|
FatalError(..),
|
||||||
|
panic,
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Base (Show)
|
||||||
|
import Data.Text(Text)
|
||||||
|
import Control.Exception as X
|
||||||
|
|
||||||
|
-- | Uncatchable exceptions thrown and never caught.
|
||||||
|
data FatalError = FatalError { msg :: Text }
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
instance Exception FatalError
|
||||||
|
|
||||||
|
panic :: Text -> a
|
||||||
|
panic a = throw (FatalError a)
|
||||||
@@ -28,6 +28,7 @@ import Functor as X
|
|||||||
import Either as X
|
import Either as X
|
||||||
import Applicative as X
|
import Applicative as X
|
||||||
import Conv as X
|
import Conv as X
|
||||||
|
import Panic as X
|
||||||
|
|
||||||
import Base as Base hiding (
|
import Base as Base hiding (
|
||||||
putStr
|
putStr
|
||||||
|
|||||||
Reference in New Issue
Block a user