View Source Bio.Enum (bio_ex_sequence v0.1.1)
Implements a wrapper around the Enum
module's public interface.
The semantics of the Enum
module don't always match up with what I would think
is best for certain cases. The best example of this is the slide/3
function.
Because of the Enum
implementation, there is no way to coerce the return
value back into a struct. So for example, given a Bio.Sequence.DnaStrand
it
would return a list of graphemes. This is not what I want users to expect.
That said, there are other functions that do behave well. Or at the very least, their semantics seem meaningfully useful. So in order to preserve the maximum utility, I wrap the module.
The expectation should be as follows:
Enum
functions will return bare data.
Bio.Enum
functions will return the closest thing to the struct as is
reasonable.
There are cases where it doesn't make much sense to return more than is
required. For example, the Bio.Enum.at/2
function will return a binary
grapheme. I have a hard time imagining a case where the user would want a
struct with a sequence of a single character instead of the character itself.
Contrast that with the Enum.at/2
function, which will return a raw char.
Summary
Types
@type acc() :: any()
@type default() :: any()
@type element() :: any()
@type index() :: integer()
@type t() :: Enumerable.t()