Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/over...

You can do all sorts of things with them. Use them like symbols in Scheme, say to name fields `get #name user` or to access database tables, etc.

But what's even more interesting is that the name is reflected up into the type. `get #name user` won't fail at runtime. Your database table name can be checked at compile time.



Ah, OverloadedLabels – I've only seen them in the `get #name user` use-case. I feel like Scheme/Lisp symbols are used quite a bit more generally, but maybe it's just not caught on yet in Haskell, also other features fill the same roles (e.g. in many lisps you can unquote a symbol and use it as the function of that name; people also often use them similarly to data constructors for pattern matching).




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

Search: