Hacker News new | past | comments | ask | show | jobs | submit login

It’s definitely an idea which I’ve seen people wish Haskell had. But requires some machinery that’s not quite in that language.

I guess it’s easy to express in a dependently typed language to an extent.




This validation dialect (and SQL dialect are main things) I used in all my web development for years using Rebol. So in Rye I made it part of the base builtins. It's nothing particularly special or complicated and could be improved to cover more cases.

I then had custom functions in Rebol that instead of argument list accepted this validation block and what it returned gor serialized into JSON and returned from the webserver. In case of valiadation error it also got automatically returned and sent back. So you defined such fucntions in a context and got an web accesible API and also you could call them on serverside to render something there (or fill in JSON directly into page that is served).

Function in Rebol (and Rye) also have a docstring and it's accesible within the language so these functions could also self-document. Show their description and validation rules if you called them with &_x=1 (as in explore mode).

Of course I tried to redo all this in Rye and make it even better for this.

Ok ... I got a little carried away ... :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: