Link Search Menu Expand Document

ReadonlyMap overview

Added in v2.5.0


Table of contents


Compactable

compact

Signature

export declare const compact: <K, A>(fa: ReadonlyMap<K, O.Option<A>>) => ReadonlyMap<K, A>

Added in v2.5.0

separate

Signature

export declare const separate: <K, A, B>(
  fa: ReadonlyMap<K, Either<A, B>>
) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>

Added in v2.5.0

Filterable

filter

Signature

export declare const filter: {
  <A, B extends A>(refinement: Refinement<A, B>): <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>
  <A>(predicate: Predicate<A>): <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, A>
}

Added in v2.5.0

filterMap

Signature

export declare const filterMap: <A, B>(f: (a: A) => O.Option<B>) => <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>

Added in v2.5.0

partition

Signature

export declare const partition: {
  <A, B extends A>(refinement: Refinement<A, B>): <K>(
    fa: ReadonlyMap<K, A>
  ) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>
  <A>(predicate: Predicate<A>): <K>(fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, A>>
}

Added in v2.5.0

partitionMap

Signature

export declare const partitionMap: <A, B, C>(
  f: (a: A) => Either<B, C>
) => <K>(fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, C>>

Added in v2.5.0

Functor

map

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.

Signature

export declare const map: <A, B>(f: (a: A) => B) => <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>

Added in v2.5.0

FunctorWithIndex

mapWithIndex

Signature

export declare const mapWithIndex: <K, A, B>(f: (k: K, a: A) => B) => (fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>

Added in v2.7.1

combinators

deleteAt

Delete a key and value from a map

Signature

export declare const deleteAt: <K>(E: Eq<K>) => (k: K) => <A>(m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>

Added in v2.5.0

filterMapWithIndex

Signature

export declare const filterMapWithIndex: <K, A, B>(
  f: (k: K, a: A) => O.Option<B>
) => (fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>

Added in v2.10.0

filterWithIndex

Signature

export declare const filterWithIndex: <K, A>(p: (k: K, a: A) => boolean) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>

Added in v2.10.0

flap

Derivable from Functor.

Signature

export declare const flap: <A>(a: A) => <E, B>(fab: ReadonlyMap<E, (a: A) => B>) => ReadonlyMap<E, B>

Added in v2.10.0

partitionMapWithIndex

Signature

export declare const partitionMapWithIndex: <K, A, B, C>(
  f: (k: K, a: A) => Either<B, C>
) => (fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, C>>

Added in v2.10.0

partitionWithIndex

Signature

export declare const partitionWithIndex: <K, A>(
  p: (k: K, a: A) => boolean
) => (fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, A>>

Added in v2.10.0

upsertAt

Insert or replace a key/value pair in a ReadonlyMap.

Signature

export declare const upsertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>

Added in v2.10.0

insertAt

Use upsertAt instead.

Signature

export declare const insertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>

Added in v2.5.0

constructors

fromFoldable

Create a map from a foldable collection of key/value pairs, using the specified Magma to combine values for duplicate keys.

Signature

export declare function fromFoldable<F extends URIS3, K, A>(
  E: Eq<K>,
  M: Magma<A>,
  F: Foldable3<F>
): <R, E>(fka: Kind3<F, R, E, readonly [K, A]>) => ReadonlyMap<K, A>
export declare function fromFoldable<F extends URIS2, K, A>(
  E: Eq<K>,
  M: Magma<A>,
  F: Foldable2<F>
): <E>(fka: Kind2<F, E, readonly [K, A]>) => ReadonlyMap<K, A>
export declare function fromFoldable<F extends URIS, K, A>(
  E: Eq<K>,
  M: Magma<A>,
  F: Foldable1<F>
): (fka: Kind<F, readonly [K, A]>) => ReadonlyMap<K, A>
export declare function fromFoldable<F, K, A>(
  E: Eq<K>,
  M: Magma<A>,
  F: Foldable<F>
): (fka: HKT<F, readonly [K, A]>) => ReadonlyMap<K, A>

Added in v2.5.0

fromMap

Signature

export declare function fromMap<K, A>(m: Map<K, A>): ReadonlyMap<K, A>

Added in v2.5.0

singleton

Create a map with one key/value pair

Signature

export declare const singleton: <K, A>(k: K, a: A) => ReadonlyMap<K, A>

Added in v2.5.0

destructors

toMap

Signature

export declare function toMap<K, A>(m: ReadonlyMap<K, A>): Map<K, A>

Added in v2.5.0

toUnfoldable

Unfolds a map into a list of key/value pairs

Signature

export declare function toUnfoldable<K, F extends URIS>(
  ord: Ord<K>,
  U: Unfoldable1<F>
): <A>(d: ReadonlyMap<K, A>) => Kind<F, readonly [K, A]>
export declare function toUnfoldable<K, F>(
  ord: Ord<K>,
  U: Unfoldable<F>
): <A>(d: ReadonlyMap<K, A>) => HKT<F, readonly [K, A]>

Added in v2.5.0

instances

Compactable

Signature

export declare const Compactable: Compactable2<'ReadonlyMap'>

Added in v2.7.0

Filterable

Signature

export declare const Filterable: Filterable2<'ReadonlyMap'>

Added in v2.7.0

Functor

Signature

export declare const Functor: Functor2<'ReadonlyMap'>

Added in v2.7.0

URI

Signature

export declare const URI: 'ReadonlyMap'

Added in v2.5.0

URI (type alias)

Signature

export type URI = typeof URI

Added in v2.5.0

getEq

Signature

export declare function getEq<K, A>(SK: Eq<K>, SA: Eq<A>): Eq<ReadonlyMap<K, A>>

Added in v2.5.0

getFilterableWithIndex

Signature

export declare function getFilterableWithIndex<K = never>(): FilterableWithIndex2C<URI, K, K>

Added in v2.5.0

getFoldable

Signature

export declare const getFoldable: <K>(O: Ord<K>) => Foldable2C<'ReadonlyMap', K>

Added in v2.10.0

getFoldableWithIndex

Signature

export declare const getFoldableWithIndex: <K>(O: Ord<K>) => FoldableWithIndex2C<'ReadonlyMap', K, K>

Added in v2.10.0

getFunctorWithIndex

Signature

export declare const getFunctorWithIndex: <K = never>() => FunctorWithIndex2C<'ReadonlyMap', K, K>

Added in v2.10.0

getMonoid

Gets Monoid instance for Maps given Semigroup instance for their values

Signature

export declare function getMonoid<K, A>(SK: Eq<K>, SA: Semigroup<A>): Monoid<ReadonlyMap<K, A>>

Added in v2.5.0

getShow

Signature

export declare function getShow<K, A>(SK: Show<K>, SA: Show<A>): Show<ReadonlyMap<K, A>>

Added in v2.5.0

getTraversable

Signature

export declare const getTraversable: <K>(O: Ord<K>) => Traversable2C<'ReadonlyMap', K>

Added in v2.10.0

getTraversableWithIndex

Signature

export declare const getTraversableWithIndex: <K>(O: Ord<K>) => TraversableWithIndex2C<'ReadonlyMap', K, K>

Added in v2.10.0

getWitherable

Signature

export declare function getWitherable<K>(O: Ord<K>): Witherable2C<URI, K> & TraversableWithIndex2C<URI, K, K>

Added in v2.5.0

readonlyMap

Use small, specific instances instead.

Signature

export declare const readonlyMap: Filterable2<'ReadonlyMap'>

Added in v2.5.0

utils

collect

Signature

export declare function collect<K>(
  O: Ord<K>
): <A, B>(f: (k: K, a: A) => B) => (m: ReadonlyMap<K, A>) => ReadonlyArray<B>

Added in v2.5.0

elem

Test whether or not a value is a member of a map

Signature

export declare function elem<A>(
  E: Eq<A>
): {
  (a: A): <K>(m: ReadonlyMap<K, A>) => boolean
  <K>(a: A, m: ReadonlyMap<K, A>): boolean
}

Added in v2.5.0

empty

Signature

export declare const empty: ReadonlyMap<never, never>

Added in v2.5.0

isEmpty

Test whether or not a map is empty

Signature

export declare function isEmpty<K, A>(d: ReadonlyMap<K, A>): boolean

Added in v2.5.0

isSubmap

Test whether or not one Map contains all of the keys and values contained in another Map

Signature

export declare function isSubmap<K, A>(
  SK: Eq<K>,
  SA: Eq<A>
): {
  (that: ReadonlyMap<K, A>): (me: ReadonlyMap<K, A>) => boolean
  (me: ReadonlyMap<K, A>, that: ReadonlyMap<K, A>): boolean
}

Added in v2.5.0

keys

Get a sorted ReadonlyArray of the keys contained in a ReadonlyMap.

Signature

export declare const keys: <K>(O: Ord<K>) => <A>(m: ReadonlyMap<K, A>) => readonly K[]

Added in v2.5.0

lookup

Lookup the value for a key in a Map.

Signature

export declare function lookup<K>(
  E: Eq<K>
): {
  (k: K): <A>(m: ReadonlyMap<K, A>) => Option<A>
  <A>(k: K, m: ReadonlyMap<K, A>): Option<A>
}

Added in v2.5.0

lookupWithKey

Lookup the value for a key in a Map. If the result is a Some, the existing key is also returned.

Signature

export declare function lookupWithKey<K>(
  E: Eq<K>
): {
  (k: K): <A>(m: ReadonlyMap<K, A>) => Option<readonly [K, A]>
  <A>(k: K, m: ReadonlyMap<K, A>): Option<readonly [K, A]>
}

Added in v2.5.0

member

Test whether or not a key exists in a map

Signature

export declare function member<K>(
  E: Eq<K>
): {
  (k: K): <A>(m: ReadonlyMap<K, A>) => boolean
  <A>(k: K, m: ReadonlyMap<K, A>): boolean
}

Added in v2.5.0

modifyAt

Signature

export declare const modifyAt: <K>(
  E: Eq<K>
) => <A>(k: K, f: (a: A) => A) => (m: ReadonlyMap<K, A>) => O.Option<ReadonlyMap<K, A>>

Added in v2.5.0

pop

Delete a key and value from a map, returning the value as well as the subsequent map

Signature

export declare function pop<K>(E: Eq<K>): (k: K) => <A>(m: ReadonlyMap<K, A>) => Option<readonly [A, ReadonlyMap<K, A>]>

Added in v2.5.0

size

Calculate the number of key/value pairs in a map

Signature

export declare function size<K, A>(d: ReadonlyMap<K, A>): number

Added in v2.5.0

toReadonlyArray

Get a sorted ReadonlyArray of the key/value pairs contained in a ReadonlyMap.

Signature

export declare const toReadonlyArray: <K>(O: Ord<K>) => <A>(m: ReadonlyMap<K, A>) => readonly (readonly [K, A])[]

Added in v2.5.0

updateAt

Signature

export declare const updateAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => O.Option<ReadonlyMap<K, A>>

Added in v2.5.0

values

Get a sorted ReadonlyArray of the values contained in a ReadonlyMap.

Signature

export declare const values: <A>(O: Ord<A>) => <K>(m: ReadonlyMap<K, A>) => readonly A[]

Added in v2.5.0