'evolve' Breaks w/ Partial Structs
See original GitHub issueš Bug report
evolve
, as currently defined, exhibits strange behavior re: partial fields
Current Behavior
Given:
interface A {
a?: 'a';
b?: 'b';
c?: 'c';
}
const a: A = {};
const b = F.pipe(
a,
evolve({
a: fromNullable,
b: fromNullable,
c: fromNullable,
})
);
runtime value of b = {}
Expected behavior
runtime value of b = {
a: O.none,
b: O.none,
c: O.none
}
Reproducible example
Suggested solution(s)
New implementation for evolve
(keeping the same type signature)
Additional context
Originally posted by @kalda341 here
Your environment
Which versions of fp-ts are affected by this issue? Did this work in previous versions of fp-ts?
Software | Version(s) |
---|---|
fp-ts | 2.11.5 |
TypeScript | 4.5.4 |
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Possibility to makes classes/structs partial as C# language
C# language allows developers to make its classes partial . It is possible to split the definition of class, struct or interface over...
Read more >Double-Strand DNA Breaks | Learn Science at Scitable - Nature
The genome of a cell is continuously damaged, which is inevitable because DNA damage often arises as a result of normal cellular processes....
Read more >Long-time evolution of interfacial structure of partial wetting
Abstract. When a solid plate is withdrawn from a partially wetting liquid, a liquid layer dewets the moving substrate. High-speed imagingĀ ...
Read more >Regulation of Error-Prone DNA Double-Strand Break Repair ...
To deal with these breaks, cells have evolved a variety of robust and ... These secondary structures serve as primers for limited DNAĀ ......
Read more >Partial Dislocation - an overview | ScienceDirect Topics
A partial dislocation glides on the slip plane, and a stacking fault arises ... The SFE of metals and alloys with fcc crystal...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think a lot of fp-ts users would agree w/ you that jsās treatment and use of
undefined
is frustrating - thatās why weāve avoided it in favor ofOption
, and to some extent pretended it wasnāt there (thus this issue)Oh wow I didnāt know about āexact optional property typesā. That could even motivate the use of
Option
instead ofundefined
in these cases - a missing key really isnāt anundefined
value at all. Imo that flag is proof that some developers want to treat āmissing keyā as separate from āundefinedāMaybe it makes sense to conditionally use a type of
Option<A | undefined>
orOption<A>
depending on whether that property is enabled. Something like this, maybe? Playground (excludedOptionalPropertyTypes enabled), Playground (excludedOptionalPropertyTypes disabled)Thatās great, Iām glad you like them! Ok it sounds like we have
Just a note: this already exists for Eq, inside the module
io-ts
. Maybe āsemigroupā and āmonoidā also belong there? Although itās hard to see how those are ādecodingā or āencodingā values in a runtime type system