relude-0.4.0: Custom prelude from Kowainik

Copyright(c) 2018 Kowainik
LicenseMIT
MaintainerKowainik <xrom.xkov@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Relude.Extra.Map

Contents

Description

Contains implementation of polymorhic type classes for data types Set and Map.

Synopsis

Documentation

class StaticMap t where Source #

Read-only map or set. Contains polymorphic functions which work for both sets and maps.

Associated Types

type Key t :: Type Source #

type Val t :: Type Source #

Methods

size :: t -> Int Source #

lookup :: Key t -> t -> Maybe (Val t) Source #

member :: Key t -> t -> Bool Source #

Instances
StaticMap IntSet Source # 
Instance details

Defined in Relude.Extra.Map

Associated Types

type Key IntSet :: Type Source #

type Val IntSet :: Type Source #

StaticMap (IntMap v) Source # 
Instance details

Defined in Relude.Extra.Map

Associated Types

type Key (IntMap v) :: Type Source #

type Val (IntMap v) :: Type Source #

Methods

size :: IntMap v -> Int Source #

lookup :: Key (IntMap v) -> IntMap v -> Maybe (Val (IntMap v)) Source #

member :: Key (IntMap v) -> IntMap v -> Bool Source #

Ord a => StaticMap (Set a) Source # 
Instance details

Defined in Relude.Extra.Map

Associated Types

type Key (Set a) :: Type Source #

type Val (Set a) :: Type Source #

Methods

size :: Set a -> Int Source #

lookup :: Key (Set a) -> Set a -> Maybe (Val (Set a)) Source #

member :: Key (Set a) -> Set a -> Bool Source #

(Eq a, Hashable a) => StaticMap (HashSet a) Source # 
Instance details

Defined in Relude.Extra.Map

Associated Types

type Key (HashSet a) :: Type Source #

type Val (HashSet a) :: Type Source #

Methods

size :: HashSet a -> Int Source #

lookup :: Key (HashSet a) -> HashSet a -> Maybe (Val (HashSet a)) Source #

member :: Key (HashSet a) -> HashSet a -> Bool Source #

Ord k => StaticMap (Map k v) Source # 
Instance details

Defined in Relude.Extra.Map

Associated Types

type Key (Map k v) :: Type Source #

type Val (Map k v) :: Type Source #

Methods

size :: Map k v -> Int Source #

lookup :: Key (Map k v) -> Map k v -> Maybe (Val (Map k v)) Source #

member :: Key (Map k v) -> Map k v -> Bool Source #

(Eq k, Hashable k) => StaticMap (HashMap k v) Source # 
Instance details

Defined in Relude.Extra.Map

Associated Types

type Key (HashMap k v) :: Type Source #

type Val (HashMap k v) :: Type Source #

Methods

size :: HashMap k v -> Int Source #

lookup :: Key (HashMap k v) -> HashMap k v -> Maybe (Val (HashMap k v)) Source #

member :: Key (HashMap k v) -> HashMap k v -> Bool Source #

class StaticMap t => DynamicMap t where Source #

Modifiable Map.

Methods

insert :: Key t -> Val t -> t -> t Source #

insertWith :: (Val t -> Val t -> Val t) -> Key t -> Val t -> t -> t Source #

delete :: Key t -> t -> t Source #

alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t Source #

Instances
DynamicMap (IntMap v) Source # 
Instance details

Defined in Relude.Extra.Map

Methods

insert :: Key (IntMap v) -> Val (IntMap v) -> IntMap v -> IntMap v Source #

insertWith :: (Val (IntMap v) -> Val (IntMap v) -> Val (IntMap v)) -> Key (IntMap v) -> Val (IntMap v) -> IntMap v -> IntMap v Source #

delete :: Key (IntMap v) -> IntMap v -> IntMap v Source #

alter :: (Maybe (Val (IntMap v)) -> Maybe (Val (IntMap v))) -> Key (IntMap v) -> IntMap v -> IntMap v Source #

Ord k => DynamicMap (Map k v) Source # 
Instance details

Defined in Relude.Extra.Map

Methods

insert :: Key (Map k v) -> Val (Map k v) -> Map k v -> Map k v Source #

insertWith :: (Val (Map k v) -> Val (Map k v) -> Val (Map k v)) -> Key (Map k v) -> Val (Map k v) -> Map k v -> Map k v Source #

delete :: Key (Map k v) -> Map k v -> Map k v Source #

alter :: (Maybe (Val (Map k v)) -> Maybe (Val (Map k v))) -> Key (Map k v) -> Map k v -> Map k v Source #

(Eq k, Hashable k) => DynamicMap (HashMap k v) Source # 
Instance details

Defined in Relude.Extra.Map

Methods

insert :: Key (HashMap k v) -> Val (HashMap k v) -> HashMap k v -> HashMap k v Source #

insertWith :: (Val (HashMap k v) -> Val (HashMap k v) -> Val (HashMap k v)) -> Key (HashMap k v) -> Val (HashMap k v) -> HashMap k v -> HashMap k v Source #

delete :: Key (HashMap k v) -> HashMap k v -> HashMap k v Source #

alter :: (Maybe (Val (HashMap k v)) -> Maybe (Val (HashMap k v))) -> Key (HashMap k v) -> HashMap k v -> HashMap k v Source #

(!?) :: StaticMap t => t -> Key t -> Maybe (Val t) infixl 9 Source #

Operator version of lookup function.

notMember :: StaticMap t => Key t -> t -> Bool Source #

Inverse of member function.

lookupDefault Source #

Arguments

:: StaticMap t 
=> Val t

Default value to return.

-> Key t

Key to search

-> t

Container to search

-> Val t 

Return the value to which the specified key is mapped, or the default value if this map contains no mapping for the key.

To pairs

toPairs :: (IsList t, Item t ~ (a, b)) => t -> [(a, b)] Source #

Converts the structure to the list of the key-value pairs.

>>> toPairs (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
[('a',"xxx"),('b',"yyy")]

keys :: (IsList t, Item t ~ (a, b)) => t -> [a] Source #

Converts the structure to the list of the keys.

>>> keys (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
"ab"

elems :: (IsList t, Item t ~ (a, b)) => t -> [b] Source #

Converts the structure to the list of the values.

>>> elems (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
["xxx","yyy"]