module Hedgehog.Extras.Stock.CallStack
  ( callerModuleName
  ) where

import           Data.Function
import           Data.Maybe
import           Data.String
import           Data.Tuple
import           GHC.Stack (HasCallStack, callStack, getCallStack, srcLocModule)

-- | Get the module name of the caller.
callerModuleName :: HasCallStack => String
callerModuleName :: HasCallStack => String
callerModuleName = forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"<no-module>" (SrcLoc -> String
srcLocModule forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd) (forall a. [a] -> Maybe a
listToMaybe (CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack))