Module

Record.ExtraSrghma.MapValuesWithIndex

Package
purescript-record-extra-srghma
Repository
srghma/purescript-record-extra-srghma

#mapValuesWithIndex Source

mapValuesWithIndex :: forall row rowList a b row'. RowToList row rowList => MapValuesWithIndex rowList row a b () row' => (String -> a -> b) -> Record row -> Record row'

Like mapRecord from https://github.com/justinwoo/purescript-record-extra but mapRecordWithIndex The 'mapValuesWithIndex' function allows you to transform the values of a record, with access to the index (as the field name) and the value.

Example usage:

let record = { name: "Alice", age: 25 }
let result = mapValuesWithIndex (\name value -> name ++ ": " ++ show value) record
-- result will be: { name: "name: Alice", age: "age: 25" }

#MapValuesWithIndex Source

class MapValuesWithIndex :: RowList Type -> Row Type -> Type -> Type -> Row Type -> Row Type -> Constraintclass MapValuesWithIndex (rowList :: RowList Type) (row :: Row Type) a b (from :: Row Type) (to :: Row Type) | rowList -> row a b from to where

Type class for transforming record values based on field names and values.

Members

Instances