    -- | Non chart specific utility functions.
    module Graphics.Rendering.Chart.Utils(
        isValidNumber,
        log10,
        maybeM,
        whenJust,
      ) where

    -- | Checks if the given value is and actual numeric value and not
    --   a concept like NaN or infinity.
    isValidNumber :: (RealFloat a) => a -> Bool
    isValidNumber :: forall a. RealFloat a => a -> Bool
    isValidNumber a
    v = Bool -> Bool
    not (a -> Bool
    forall a. RealFloat a => a -> Bool
    isNaN a
    v) Bool -> Bool -> Bool
    && Bool -> Bool
    not (a -> Bool
    forall a. RealFloat a => a -> Bool
    isInfinite a
    v)

    -- | Shorthand for the decimal logarithm
    log10 :: (Floating a) => a -> a
    log10 :: forall a. Floating a => a -> a
    log10 = a -> a -> a
    forall a. Floating a => a -> a -> a
    logBase a
    10

    -- | Version of 'Prelude.maybe' that returns a monadic value.
    maybeM :: (Monad m) => b -> (a -> m b) -> Maybe a -> m b
    maybeM :: forall (m :: * -> *) b a.
    Monad m =>
    b -> (a -> m b) -> Maybe a -> m b
    maybeM b
    v = m b -> (a -> m b) -> Maybe a -> m b
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (b -> m b
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return b
    v)

    -- | Specialization to ()
    whenJust :: (Monad m) => Maybe a -> (a -> m ()) -> m ()
    whenJust :: forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
    whenJust Maybe a
    m a -> m ()
    f = () -> (a -> m ()) -> Maybe a -> m ()
    forall (m :: * -> *) b a.
    Monad m =>
    b -> (a -> m b) -> Maybe a -> m b
    maybeM () a -> m ()
    f Maybe a
    m