joneshf / purescript-option

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Documentation for alter function

ntwilson opened this issue · comments

Currently the alter function says:

Manipulates the values of an option.
If the field exists in the option, the given function is applied to the value.
If the field does not exist in the option, there is no change to the option.

I don't believe this is accurate. From my testing:

someOption :: Option ( foo :: Boolean, bar :: Int )
someOption = insert (Proxy :: _ "bar") 31 empty

anotherOption :: Option.Option ( foo :: Boolean, bar :: Int )
anotherOption = Option.alter { foo: (\(_ :: Maybe Boolean) -> Just false), bar: (\(_ :: Maybe Int) -> Just 41) } someOption

> anotherOption 
(Option.fromRecord { bar: 41, foo: false })

So it seems alter is able to adjust fields that don't exist in the option. I think the existing documentation reflects the modify' function behavior instead.

Would you accept a PR if I took a shot at reworking the alter docs?

Sorry about the very delayed response. I think what you're saying is correct. Lemme take a minute to get up to speed first on how things work here again (haven't looked at this package in over a year).