I was experimenting a bit with how OSlash operates with Python's inherent mutability.
While you can't assign within a map, you can still mutate variables outside of the context, for instance a dict:
In [77]: y = Just(1)
In [78]: y.map(lambda x: d.pop('hoge'))
Out[78]: Just 10
In [79]: d
Out[79]: {}
This is troublesome in a context in which you would want to map with a function that relies on the mutability of an object - for instance splitting one dict in to two via popping the appropriate variables in to a second dict, while maintaining the structure of the initial dict.
Obviously this can be avoided by copying the dict, either outside the context or within the function. I would however expect that applying something in a functional context would absolutely not mutate anything. I don't know if this is avoidable in a way that isn't wasteful (simply implementing a copy within the library wouldn't be ideal) but it caught my interest.
I was experimenting a bit with how OSlash operates with Python's inherent mutability.
While you can't assign within a map, you can still mutate variables outside of the context, for instance a dict:
This is troublesome in a context in which you would want to map with a function that relies on the mutability of an object - for instance splitting one dict in to two via popping the appropriate variables in to a second dict, while maintaining the structure of the initial dict.
Obviously this can be avoided by copying the dict, either outside the context or within the function. I would however expect that applying something in a functional context would absolutely not mutate anything. I don't know if this is avoidable in a way that isn't wasteful (simply implementing a copy within the library wouldn't be ideal) but it caught my interest.