    {- |
    Module      :  Data.MapLike.Instances
    Copyright   :  (c) Eduard Sergeev 2011
    License     :  BSD-style (see the file LICENSE)

    Maintainer  :  eduard.sergeev@gmail.com
    Stability   :  experimental
    Portability :  non-portable (multi-param classes, functional dependencies)

    Defines MapLike instances declaration for standard data types

    -}

    {-# LANGUAGE NoImplicitPrelude, MultiParamTypeClasses, FlexibleInstances #-}

    module Data.MapLike.Instances (

       MapLike(..)

    ) where

    import Data.Ord
    import Data.Int
    import Data.MapLike
    import qualified Data.Map as M
    import qualified Data.IntMap as IM

    -- | Data.Map is a default implementation (not the fastest but well-known)
    instance Ord k => MapLike (M.Map k v) k v where
        add :: k -> v -> Map k v -> Map k v
    add = k -> v -> Map k v -> Map k v
    forall k v. Ord k => k -> v -> Map k v -> Map k v
    M.insert
        lookup :: k -> Map k v -> Maybe v
    lookup = k -> Map k v -> Maybe v
    forall k v. Ord k => k -> Map k v -> Maybe v
    M.lookup

    -- | Data.IntMap is usually more efficient that Data.Map if @k :: Int@
    instance MapLike (IM.IntMap v) Int v where
        {-# INLINE add #-}
        add :: Int -> v -> IntMap v -> IntMap v
    add = Int -> v -> IntMap v -> IntMap v
    forall v. Int -> v -> IntMap v -> IntMap v
    IM.insert
        {-# INLINE lookup #-}
        lookup :: Int -> IntMap v -> Maybe v
    lookup = Int -> IntMap v -> Maybe v
    forall v. Int -> IntMap v -> Maybe v
    IM.lookup