evilsoft / crocks

A collection of well known Algebraic Data Types for your utter enjoyment.
https://crocks.dev
ISC License
1.59k stars 102 forks source link

`Monoid(undefined)` should be handled according to the rules on the Monoid #371

Open dalefrancis88 opened 5 years ago

dalefrancis88 commented 5 years ago

Is your feature request related to a problem? Please describe. A question was raise https://github.com/evilsoft/crocks/issues/301 by @bennypowers. Floating the idea of m(nil) returning an empty for the monoid.

Describe the solution you'd like We will need to consider the behaviour of each monoid but if undefined hits the monoid and it is not expected we should handle it accordingly. In the case of Any and All which utilize coercion, should coerce into a false. All other Monoid should throw if their carrier type cannot deal with the unit.

Describe alternatives for how you do this now @bennypowers can you add here if you have any

Code

Additional context

bennypowers commented 5 years ago

yeah I suppose the alternative would be mapping over the input with some function that coerces for you