module Data.Convertible.Instances.Map()
where
import Data.Convertible.Base
import qualified Data.Map as Map
instance Ord k => Convertible [(k, a)] (Map.Map k a) where
safeConvert :: [(k, a)] -> ConvertResult (Map k a)
safeConvert = Map k a -> ConvertResult (Map k a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Map k a -> ConvertResult (Map k a))
-> ([(k, a)] -> Map k a) -> [(k, a)] -> ConvertResult (Map k a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(k, a)] -> Map k a
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
instance Convertible (Map.Map k a) [(k, a)] where
safeConvert :: Map k a -> ConvertResult [(k, a)]
safeConvert = [(k, a)] -> ConvertResult [(k, a)]
forall (m :: * -> *) a. Monad m => a -> m a
return ([(k, a)] -> ConvertResult [(k, a)])
-> (Map k a -> [(k, a)]) -> Map k a -> ConvertResult [(k, a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map k a -> [(k, a)]
forall k a. Map k a -> [(k, a)]
Map.toList