Why ReadonlyXyz? #1609
-
In responding to #1608 @mlegenhausen highlighted to me the abundance and use of the ReadonlyXyz type classes ( Or, if that is correct then what's the intention behind these? Documentation purposes? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Me again 😅
This only holds if you use In |
Beta Was this translation helpful? Give feedback.
Me again 😅
This only holds if you use
fp-ts
functions for data manipulations, but not for the functions that are defined on the non-readonly interfaces. AnArray
still has apush
function which will mutate the array. On anReadonlyArray
thepush
function is not defined at all. So using theReadonly
variants gives you simply more type safety, but with a "cost" that you need to explicitly convert to a mutable array when e. g. calling APIs that expects a mutable data structure.In
fp-ts@3
the mutable versions ofArray
,Record
,NonEmptyArray
andMap
will be deprecated and will only con…