enum-fp
enum-fp copied to clipboard
Needs use cases and more examples
I've been trying to work through some of the examples with limited success. For example https://github.com/phenax/enum-fp#pattern-matching works fine,
However https://github.com/phenax/enum-fp#safely-work-with-emptyinvalid-states doesn't include getUser()
and I don't know what it is expected to return.
Other examples like: https://github.com/phenax/enum-fp#in-the-functional-world do not show how to actually use them.
I also tried https://gist.github.com/phenax/e841e54a2826c1d52b6dce3c493ef792#file-maybe-js from the Medium article https://medium.com/@phenax5/writing-cleaner-and-safer-javascript-with-sum-types-bec9c68ba7aa and it fails because user
is not defined anywhere in Maybe.match(getFirstName(user)
and I also assume that isUserValid()
is missing.
For folks with a good understanding of FP some of this may not be such a problem, but for someone like me who is very new to FP I have very little understanding of many of the concepts included with enum-fp
and more concrete executable examples along with more documentation would help greatly.
I have no doubt enum-fp
provides some really useful tools to help with our Javascript development but this mostly alludes me right now.
@nevf. Thank you for bringing up theses issues. In retrospect, I feel like I may have posted the example with a tunnel vision perspective towards functional programming.
- The getUser was just a function that returns a user object. I'll update the example to get rid of that to make things clearer.
- I'll add a description and some references to the Maybe and Either monads so everyone has a reference for how it works.
-
user
is a normal object with the firstName property. I'll define user in the example so that it is clearer.
@phenax Many thanks, I look forward to the updates and trying the examples again.