[Haskell-cafe] Library for overloaded indexing (a la (!))
Roman Cheplyaka
roma at ro-che.info
Fri Aug 14 06:44:56 UTC 2015
On 14/08/15 09:21, William Yager wrote:
> If I mis-index a vector, I don't want it to fail silently with mempty; I
> want it to fail loudly. What you've described (default value on
> out-of-bounds access) is not correct for most use cases. Sometimes
> exceptions are the right behavior.
Precisely.
«An element is not found, so I'll just return 0[*] or "".» Even
JavaScript knows better than that.
Granted, there *is* a way to use this API properly (using Maybe-like
monoids). But it's also easy to make the wrong code type-check without
realizing it.
[*] that's essentially what Nikita proposed earlier in the thread
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150814/4c0e0b0f/attachment.sig>
More information about the Haskell-Cafe
mailing list