A quest for a "standard" Erlang library with uniform, composable abstractions.
A quest for a "standard" library with uniform, composable abstractions.
Originally motivated by a desire for an error monad and generic option type operations, and stood for Higher Order Programming in Erlang. Soon after, I wished all standard containers used consistent conventions and protocols (such as consistent accessor names, argument positioning rules and expression of semantics with option and result types).
Here lies an experiment to see what something like that could look like. As all proper experiments should, this one is used daily in production projects (hence the high-ish version number, 'cause semver).
I entertain any forward-thinking library design ideas, but more than anything else, these are influenced by Jane Street's Core of the OCaml world.
hope_foo:t()
, not hope_foo:foo()
#foo{}
or #t{}
(Though{t, ..}
in stack traces is less#t{..}
as-define(T, ?MODULE). -record(?T, {..}).
, which may be a bit ugly. Still#hope_module_record{}
hope_module
(thisA class of burritos, used for expressing sequences of operations on some data
type. Defined in hope_gen_monad
, implemented as:
hope_result
: for composition of common functions returning{ok, Val} | {error, Reason}
. An alternative to exceptions, which makes theData.Either a b
, Jane Street Core's (OCaml) ('a, 'b) Result.t
, Rust'sResult<T, E>
hope_option
: for expressing and composing the intention that the value mayundefined
(which isnull
). Analogous to ML's (SML, OCaml, etc)'a Option.t
, Rust's Option<T>
and Haskell's Data.Maybe a
1.A class of abstract data types to which we have exclusive access and can put things in and take them out. See issue #9
Defined in hope_gen_dictionary
, implemented as:
hope_kv_list
. Equivalent to orddict/proplist. Operations implemented withlists
module, where possibleTBD:
hope_hash_tbl
. API around stdlib's dict
hope_gb_dict
. API around stdlib's gb_trees
TBD:
hope_hash_set
. API around stdlib's sets
hope_gb_set
. API around stdlib's gb_sets
TBD
Should include both FIFO (queue) and LIFO (stack), so that user can swap if a different order is desired.
Should we attempt to include priority queues or make them a separate abstract type?
TBD
Not yet defined and only partially implemented as:
hope_list
A class of abstract systems to which we share access with an unknown number of users and can make requests to perform operations which may not get done for any number of reasons.
TBD
See issue #11