annotated-exception-0.1.2.0: Exceptions, with checkpoints and context.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Annotation

Description

An Annotation is attached to a LocatedException. They're essentially a dynamically typed value with a convenient IsString instance. I'd recommend using something like Data.Aeson.Value or possibly something more strongly typed.

Synopsis

Documentation

newtype CallStackAnnotation Source #

A wrapper type for putting a CallStack into an Annotation. We need this because CallStack does not have an Eq instance.

Since: 0.1.0.0

data Annotation where Source #

An Annotation is a wrapper around a value that includes a Typeable constraint so we can later unpack it. It is essentially a 'Dynamic, but we also include Show and Eq so it's more useful.

Since: 0.1.0.0

Constructors

Annotation :: AnnC a => a -> Annotation 

Instances

Instances details
Eq Annotation Source #

Since: 0.1.0.0

Instance details

Defined in Data.Annotation

Show Annotation Source #

Since: 0.1.0.0

Instance details

Defined in Data.Annotation

IsString Annotation Source #

Since: 0.1.0.0

Instance details

Defined in Data.Annotation

type AnnC a = (Typeable a, Eq a, Show a) Source #

The constraints that the value inside an Annotation must have.

We want Typeable so we can do cast and potentially get more useful information out of it.

Since: 0.1.0.0

toAnnotation :: AnnC a => a -> Annotation Source #

Wrap a value in an Annotation.

Since: 0.1.0.0

castAnnotation :: forall a. Typeable a => Annotation -> Maybe a Source #

Attempt to cast the underlying value out of an Annotation.

Since: 0.1.0.0

tryAnnotation :: forall a. Typeable a => Annotation -> Either a Annotation Source #

Attempt to cast the underlying value out of an Annotation. Returns the original Annotation if the cast isn't right.

Since: 0.1.0.0

tryAnnotations :: forall a. Typeable a => [Annotation] -> ([a], [Annotation]) Source #

Attempt to cast list of Annotation into the given type. Any Annotation that is not in that form is left untouched.

Since: 0.1.0.0

annotationTypes :: [Annotation] -> Set TypeRep Source #

Returns the Set of types that are in the given annotations.

Since: 0.1.0.0

mapAnnotation :: (AnnC a, AnnC b) => (a -> b) -> Annotation -> Maybe Annotation Source #

Map a function over the given Annotation. If the types don't match up, then the whole thing returns Nothing.

Since: 0.1.0.0

mapMaybeAnnotation :: (AnnC a, AnnC b) => (a -> b) -> Annotation -> Annotation Source #

Map a function over the Annotation, leaving it unchanged if the types don't match.

Since: 0.1.0.0

callStackAnnotation :: HasCallStack => Annotation Source #

Grab an Annotation corresponding to the CallStack that is currently in scope.

Since: 0.1.0.0

callStackToAnnotation :: CallStack -> Annotation Source #

Stuff a CallStack into an Annotation via the CallStackAnnotation newtype wrapper.

Since: 0.1.0.0

callStackFromAnnotation :: CallStackAnnotation -> CallStack Source #

Attempt to convert an Annotation back into a CallStack.

Since: 0.1.0.0

callStackInAnnotations :: [Annotation] -> ([CallStack], [Annotation]) Source #

Extract the CallStacks from the [Annotation]. Any Annotation not corresponding to a CallStack will be in the second element of the tuple.

Since: 0.1.0.0

module Data.Proxy