module Slist.Containers
(
mapToVals
, mapToKeys
, mapToPairs
, setToSlist
) where
import Data.Map.Strict (Map)
import Data.Set (Set)
import Slist.Size (Size (..))
import Slist.Type (Slist (..))
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
mapToVals :: Map k v -> Slist v
mapToVals :: Map k v -> Slist v
mapToVals Map k v
m = Slist :: forall a. [a] -> Size -> Slist a
Slist
{ sList :: [v]
sList = Map k v -> [v]
forall k a. Map k a -> [a]
Map.elems Map k v
m
, sSize :: Size
sSize = Int -> Size
Size (Int -> Size) -> Int -> Size
forall a b. (a -> b) -> a -> b
$ Map k v -> Int
forall k a. Map k a -> Int
Map.size Map k v
m
}
{-# INLINE mapToVals #-}
mapToKeys :: Map k v -> Slist k
mapToKeys :: Map k v -> Slist k
mapToKeys Map k v
m = Slist :: forall a. [a] -> Size -> Slist a
Slist
{ sList :: [k]
sList = Map k v -> [k]
forall k a. Map k a -> [k]
Map.keys Map k v
m
, sSize :: Size
sSize = Int -> Size
Size (Int -> Size) -> Int -> Size
forall a b. (a -> b) -> a -> b
$ Map k v -> Int
forall k a. Map k a -> Int
Map.size Map k v
m
}
{-# INLINE mapToKeys #-}
mapToPairs :: Map k v -> Slist (k, v)
mapToPairs :: Map k v -> Slist (k, v)
mapToPairs Map k v
m = Slist :: forall a. [a] -> Size -> Slist a
Slist
{ sList :: [(k, v)]
sList = Map k v -> [(k, v)]
forall k a. Map k a -> [(k, a)]
Map.toAscList Map k v
m
, sSize :: Size
sSize = Int -> Size
Size (Int -> Size) -> Int -> Size
forall a b. (a -> b) -> a -> b
$ Map k v -> Int
forall k a. Map k a -> Int
Map.size Map k v
m
}
{-# INLINE mapToPairs #-}
setToSlist :: Set a -> Slist a
setToSlist :: Set a -> Slist a
setToSlist Set a
s = Slist :: forall a. [a] -> Size -> Slist a
Slist
{ sList :: [a]
sList = Set a -> [a]
forall a. Set a -> [a]
Set.elems Set a
s
, sSize :: Size
sSize = Int -> Size
Size (Int -> Size) -> Int -> Size
forall a b. (a -> b) -> a -> b
$ Set a -> Int
forall a. Set a -> Int
Set.size Set a
s
}
{-# INLINE setToSlist #-}