3 ms·
Haskell has almost all of these. > Instead of writing 10000500, you can write 10_000_500, or 1_00_00_500 https://ghc.gitlab.haskell.org/ghc/doc/users_guide/ex
by light_hue_1 4y ago
Haskell has almost all of these.
> Instead of writing 10000500, you can write 10_000_500, or 1_00_00_500
https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/numeric_underscores.html https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/nume...
> Balanced string literals
https://hackage.haskell.org/package/raw-strings-qq-1.1/docs/Text-RawString-QQ.html https://hackage.haskell.org/package/raw-strings-qq-1.1/docs/...
> Generalized update syntax
Use Lens. `fileName %~ max 2`
> you can write the sequence 1, 2, … n-1 as 1..<n.
Yup. `[1,2..n-1]` There's far more to it, you have access almost a SQL-like sublanguage.
> Symbols
In Haskell you use hash has a prefix instead of colon.
Haskell sadly does not do automatic lifting, no extended parameter blocks, and no kebab-case.
- unhammer 4y ago>> Symbols > In Haskell you use hash has a prefix instead of colon. Can you give an example?
- light_hue_1 4y agohttps://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/overloaded_labels.html 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.
- unhammer 4y agoAh, 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).
- still_grokking 4y agoSame goes for Scala. You could likely build "automatic lifting" this macros. "Extended parameter blocks" are just normal Scala method signatures. You can use kebab-case (though with back-ticks).