Closed kightlingerh closed 4 years ago
My bad on the .idea folder.
I actually considered insertAt as well. The underlying implementation of insertAt maps to assoc but the type signature is a little restrictive since it requires that the object to be updated have values homogeneous with the type of the value to be inserted. This is more an issue when you use assoc to add a new key value pair to an object rather than updating an existing value. My solution in my last commit is to use insertAt but cast the return type. Let me know what you think.
thanks @kightlingerh!
Added an implementation of assoc, feel free to make any changes or give me comments/suggestions.
I decided not to map to getObjectSemigroup since it requires both arguments of concat to be of the same type. In my mind, assoc can take a random string and value and return the intersection of the object supplied and a Record<string, value>. I typically don't use it in this fashion but I decided to make it less restrictive in my initial attempt. Downside is that I don't use anything from fp-ts here though.