-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maintain JS syntax #1
Comments
Hi @edmulraney, Thanks a lot for your feedback! Of course, you can do it this way but IMHO your solution is a lot more verbose and starts to be really hard to read. My point was to re-implement the Haskell pattern guard syntax, which I find quite clean and expressive. By the way, I'm not really sure if what you suggest is really an issue (more an alternative implementation which is totally fine). Do you mind if we close it? |
Yeah sorry, close this 👍 Cheers @yamafaktory 😄 |
Thanks @edmulraney 🍻 |
I had a quick go at reducing verbosity and came up with this monstrosity:
Possible alternative to running VM, and would run in the browser. |
@edmulraney This sounds really great 👍. As I want to stick with the Haskell pattern guard syntax and with a tagged template literal, I've modified your code as follow https://jsfiddle.net/yamafaktory/92mgnnpo/. I think this could definitely be a great improvement as it would run in the browser (if supported, or could be transpiled). But in this case, maybe you can create a PR for what you did? |
Ah cool, yeah if you're interested I can modify what I've done to work with the guard syntax you're after. (as a PR) |
Actually not that much needs to be done, the quick fiddle I did reusing your code mixed with mine is already working. We can drop the class in https://github.com/yamafaktory/pattern-guard/blob/master/index.js#L3 and simply export a function like you did. |
Awwesome 👍 I think the only issue was that some browsers will fail on the es6 stuff (const {destructure}). |
Had a go at making it parse the guard as a string just using string manipulation: https://goo.gl/crHzUo
|
Thanks a lot for your work, I'm going to think about all of these implementations. I don't want to use Ramda (which is great) just for the benefit of the |
Fair do's. Ramda was just for POC ;) |
Definitely, for aesthetics, many libraries are going this way recently (can think of https://github.com/hyperapp/hyperapp#html for example). |
Hey, cool project. I might be missing the point of the pattern guard but could we not do the same thing in plain JS:
The text was updated successfully, but these errors were encountered: