Copyright | (c) 2023 GYELD GMBH |
---|---|
License | Apache 2.0 |
Maintainer | [email protected] |
Stability | develop |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Synopsis
- data Natural
- data Void
- type Type = TYPE LiftedRep
- data CallStack
- class Generic a
- class IsString a where
- fromString ∷ String → a
- data Proxy (t ∷ k) = Proxy
- newtype Const a (b ∷ k) = Const {
- getConst ∷ a
- class (Typeable e, Show e) ⇒ Exception e
- newtype Identity a = Identity {
- runIdentity ∷ a
- data Set a
- data Map k a
- type Constraint = CONSTRAINT LiftedRep
- data Text
- class Contravariant (f ∷ Type → Type) where
- class FromJSON a where
- parseJSON ∷ Value → Parser a
- parseJSONList ∷ Value → Parser [a]
- omittedField ∷ Maybe a
- class ToJSON a where
- toJSON ∷ a → Value
- toEncoding ∷ a → Encoding
- toJSONList ∷ [a] → Value
- toEncodingList ∷ [a] → Encoding
- omitField ∷ a → Bool
- type HasCallStack = ?callStack ∷ CallStack
- data (a ∷ k) :~: (b ∷ k) where
- class PrintfArg a where
- formatArg ∷ a → FieldFormatter
- parseFormat ∷ a → ModifierParser
- data Some (tag ∷ k → Type) where
- bimap ∷ Bifunctor p ⇒ (a → b) → (c → d) → p a c → p b d
- first ∷ Bifunctor p ⇒ (a → b) → p a c → p b c
- second ∷ Bifunctor p ⇒ (b → c) → p a b → p a c
- void ∷ Functor f ⇒ f a → f ()
- join ∷ Monad m ⇒ m (m a) → m a
- toList ∷ Foldable t ⇒ t a → [a]
- foldl' ∷ Foldable t ⇒ (b → a → b) → b → t a → b
- liftA2 ∷ Applicative f ⇒ (a → b → c) → f a → f b → f c
- guard ∷ Alternative f ⇒ Bool → f ()
- absurd ∷ Void → a
- when ∷ Applicative f ⇒ Bool → f () → f ()
- ap ∷ Monad m ⇒ m (a → b) → m a → m b
- isJust ∷ Maybe a → Bool
- fromMaybe ∷ a → Maybe a → a
- catMaybes ∷ Filterable f ⇒ f (Maybe a) → f a
- mapMaybe ∷ Filterable f ⇒ (a → Maybe b) → f a → f b
- on ∷ (b → b → c) → (a → b) → a → a → c
- isAlphaNum ∷ Char → Bool
- find ∷ Foldable t ⇒ (a → Bool) → t a → Maybe a
- sortBy ∷ (a → a → Ordering) → [a] → [a]
- catch ∷ Exception e ⇒ IO a → (e → IO a) → IO a
- throwIO ∷ Exception e ⇒ e → IO a
- foldM ∷ (Foldable t, Monad m) ⇒ (b → a → m b) → b → t a → m b
- unless ∷ Applicative f ⇒ Bool → f () → f ()
- forM_ ∷ (Foldable t, Monad m) ⇒ t a → (a → m b) → m ()
- coerce ∷ ∀ {k ∷ RuntimeRep} (a ∷ TYPE k) (b ∷ TYPE k). Coercible a b ⇒ a → b
- (&) ∷ a → (a → b) → b
- forM ∷ (Traversable t, Monad m) ⇒ t a → (a → m b) → m (t b)
- maximumBy ∷ Foldable t ⇒ (a → a → Ordering) → t a → a
- minimumBy ∷ Foldable t ⇒ (a → a → Ordering) → t a → a
- (>>>) ∷ ∀ {k} cat (a ∷ k) (b ∷ k) (c ∷ k). Category cat ⇒ cat a b → cat b c → cat a c
- (<&>) ∷ Functor f ⇒ f a → (a → b) → f b
- isHexDigit ∷ Char → Bool
- fromRight ∷ b → Either a b → b
- printf ∷ PrintfType r ⇒ String → r
- encodeUtf8 ∷ Text → ByteString
- rightToMaybe ∷ Either a b → Maybe b
- ifor_ ∷ (FoldableWithIndex i t, Applicative f) ⇒ t a → (i → a → f b) → f ()
- itoList ∷ FoldableWithIndex i f ⇒ f a → [(i, a)]
- withSome ∷ Some tag → (∀ (a ∷ k). tag a → b) → b
- iwither ∷ (WitherableWithIndex i t, Applicative f) ⇒ (i → a → f (Maybe b)) → t a → f (t b)
- wither ∷ (Witherable t, Applicative f) ⇒ (a → f (Maybe b)) → t a → f (t b)
- pattern TODO ∷ () ⇒ HasCallStack ⇒ a
- findFirst ∷ Foldable f ⇒ (a → Maybe b) → f a → Maybe b
- decodeUtf8Lenient ∷ ByteString → Text
- lazyDecodeUtf8Lenient ∷ ByteString → Text
- hush ∷ Either e a → Maybe a
- hoistMaybe ∷ Applicative m ⇒ Maybe b → MaybeT m b
Documentation
Natural number
Invariant: numbers <= 0xffffffffffffffff use the NS
constructor
Instances
Uninhabited data type
Since: base-4.8.0.0
Instances
CallStack
s are a lightweight method of obtaining a
partial call-stack at any point in the program.
A function can request its call-site with the HasCallStack
constraint.
For example, we can define
putStrLnWithCallStack :: HasCallStack => String -> IO ()
as a variant of putStrLn
that will get its call-site and print it,
along with the string given as argument. We can access the
call-stack inside putStrLnWithCallStack
with callStack
.
>>>
:{
putStrLnWithCallStack :: HasCallStack => String -> IO () putStrLnWithCallStack msg = do putStrLn msg putStrLn (prettyCallStack callStack) :}
Thus, if we call putStrLnWithCallStack
we will get a formatted call-stack
alongside our string.
>>>
putStrLnWithCallStack "hello"
hello CallStack (from HasCallStack): putStrLnWithCallStack, called at <interactive>:... in interactive:Ghci...
GHC solves HasCallStack
constraints in three steps:
- If there is a
CallStack
in scope -- i.e. the enclosing function has aHasCallStack
constraint -- GHC will append the new call-site to the existingCallStack
. - If there is no
CallStack
in scope -- e.g. in the GHCi session above -- and the enclosing definition does not have an explicit type signature, GHC will infer aHasCallStack
constraint for the enclosing definition (subject to the monomorphism restriction). - If there is no
CallStack
in scope and the enclosing definition has an explicit type signature, GHC will solve theHasCallStack
constraint for the singletonCallStack
containing just the current call-site.
CallStack
s do not interact with the RTS and do not require compilation
with -prof
. On the other hand, as they are built up explicitly via the
HasCallStack
constraints, they will generally not contain as much
information as the simulated call-stacks maintained by the RTS.
A CallStack
is a [(String, SrcLoc)]
. The String
is the name of
function that was called, the SrcLoc
is the call-site. The list is
ordered with the most recently called function at the head.
NOTE: The intrepid user may notice that HasCallStack
is just an
alias for an implicit parameter ?callStack :: CallStack
. This is an
implementation detail and should not be considered part of the
CallStack
API, we may decide to change the implementation in the
future.
Since: base-4.8.1.0
Instances
IsList CallStack | Be aware that 'fromList . toList = id' only for unfrozen Since: base-4.9.0.0 |
Show CallStack | Since: base-4.9.0.0 |
NFData CallStack | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NoThunks CallStack | Since CallStacks can't retain application data, we don't want to check them for thunks at all |
type Item CallStack | |
Defined in GHC.IsList | |
type Code CallStack | |
type DatatypeInfoOf CallStack | |
Defined in Generics.SOP.Instances type DatatypeInfoOf CallStack = 'ADT "GHC.Stack.Types" "CallStack" '['Constructor "EmptyCallStack", 'Constructor "PushCallStack", 'Constructor "FreezeCallStack"] '['[] ∷ [StrictnessInfo], '['StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy, 'StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy, 'StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy], '['StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy]] |
Representable types of kind *
.
This class is derivable in GHC with the DeriveGeneric
flag on.
A Generic
instance must satisfy the following laws:
from
.to
≡id
to
.from
≡id