[Haskell-cafe] naming convention for maybes?
Evan Laforge
qdunkan at gmail.com
Fri Apr 22 19:14:03 CEST 2011
Here's a simple issue that's been with me for a while. As do many
people, I use plural variable names for lists, so if a Block as called
'block' then [Block] is 'blocks'.
The other pattern that comes up a lot is 'Maybe Block'. When I have
to name it, I call it 'maybe_block', e.g.
maybe_block <- lookup something
case maybe_block of
Just block -> ...
However, this maybe_ prefix is rather long and unwieldy. I have
considered things like 'm' or 'mb' but they don't suggest Maybe to me.
An 'm' prefix or suffix is already implying 'monad'. If '?' were
allowed in identifiers I could use it as a suffix. I could just
append 'q' and get used to it... lispers did it with 'p' after all. I
suppose 'mby' could be ok, but for some reason it just looks ugly to
me. 'opt' looks ok, I suppose, but 'optional' doesn't cover the full
range of Maybe's usage (i.e. it's strange to call a failed lookup
result "optional"). Does anyone else have a nice convention for this?
Hopefully something short but intuitive and nicely reading like the
plural convention?
More information about the Haskell-Cafe
mailing list