{-# OPTIONS_GHC -Wno-orphans #-}

-- |
-- Copyright: © 2023–2026 Jonathan Knowles
-- License: Apache-2.0
--
module Data.MonoidMap.NoThunks
    (
    -- * Introduction
    -- $_introduction
    )
    where

import Data.Map.Strict
    ( Map )
import Data.MonoidMap
    ( MonoidMap, toMap )
import NoThunks.Class
    ( NoThunks (showTypeOf, wNoThunks) )
import Prelude
    ( undefined, (.) )

-- $_introduction
-- #_introduction#
--
-- This module provides a 'NoThunks' instance for 'MonoidMap'.
--
-- This instance behaves like the 'NoThunks' instance for 'Map', except that
-- when it finds a thunk, it names 'MonoidMap' instead of 'Map' in the context
-- that it reports.
--
-- To bring this instance into scope, import this module:
--
-- @
-- import "Data.MonoidMap.NoThunks" ()
-- @
--

_importsRequiredForDocumentation :: ()
_importsRequiredForDocumentation :: ()
_importsRequiredForDocumentation = ()
  where
    _Map :: Map () ()
    _Map :: Map () ()
_Map = Map () ()
forall a. HasCallStack => a
undefined

-- | @since 0.0.0.0
instance (NoThunks k, NoThunks v) => NoThunks (MonoidMap k v) where
    showTypeOf :: Proxy (MonoidMap k v) -> String
showTypeOf Proxy (MonoidMap k v)
_ = String
"MonoidMap"
    {-# INLINE showTypeOf #-}
    wNoThunks :: Context -> MonoidMap k v -> IO (Maybe ThunkInfo)
wNoThunks Context
ctx = Context -> Map k v -> IO (Maybe ThunkInfo)
forall a. NoThunks a => Context -> a -> IO (Maybe ThunkInfo)
wNoThunks Context
ctx (Map k v -> IO (Maybe ThunkInfo))
-> (MonoidMap k v -> Map k v)
-> MonoidMap k v
-> IO (Maybe ThunkInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MonoidMap k v -> Map k v
forall k v. MonoidMap k v -> Map k v
toMap
    {-# INLINE wNoThunks #-}