{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
module GHC.Internal.Stack.Annotation where
import GHC.Internal.Base
import GHC.Internal.Data.Typeable
import GHC.Internal.Stack (SrcLoc, prettySrcLoc)
class StackAnnotation a where
displayStackAnnotation :: a -> String
stackAnnotationSourceLocation :: a -> Maybe SrcLoc
displayStackAnnotationShort :: a -> String
{-# MINIMAL displayStackAnnotation | displayStackAnnotationShort #-}
displayStackAnnotation a
ann =
a -> String
forall a. StackAnnotation a => a -> String
displayStackAnnotationShort a
ann
String -> String -> String
forall a. [a] -> [a] -> [a]
++ case a -> Maybe SrcLoc
forall a. StackAnnotation a => a -> Maybe SrcLoc
stackAnnotationSourceLocation a
ann of
Maybe SrcLoc
Nothing -> String
""
Just SrcLoc
srcLoc -> String
", called at " String -> String -> String
forall a. [a] -> [a] -> [a]
++ SrcLoc -> String
prettySrcLoc SrcLoc
srcLoc
stackAnnotationSourceLocation a
_ann = Maybe SrcLoc
forall a. Maybe a
Nothing
displayStackAnnotationShort = a -> String
forall a. StackAnnotation a => a -> String
displayStackAnnotation
data SomeStackAnnotation where
SomeStackAnnotation :: forall a. (Typeable a, StackAnnotation a) => a -> SomeStackAnnotation
instance StackAnnotation SomeStackAnnotation where
displayStackAnnotation :: SomeStackAnnotation -> String
displayStackAnnotation (SomeStackAnnotation a
a) =
a -> String
forall a. StackAnnotation a => a -> String
displayStackAnnotation a
a
stackAnnotationSourceLocation :: SomeStackAnnotation -> Maybe SrcLoc
stackAnnotationSourceLocation (SomeStackAnnotation a
a) =
a -> Maybe SrcLoc
forall a. StackAnnotation a => a -> Maybe SrcLoc
stackAnnotationSourceLocation a
a
displayStackAnnotationShort :: SomeStackAnnotation -> String
displayStackAnnotationShort (SomeStackAnnotation a
a) =
a -> String
forall a. StackAnnotation a => a -> String
displayStackAnnotationShort a
a