X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhope_dictionary.erl;fp=src%2Fhope_dictionary.erl;h=2e3a59d6d49aa69aeed522ae00ced57f1681d7ef;hb=cd69f1f3699412fbb3fa8d304f5a377d83efc8ff;hp=0000000000000000000000000000000000000000;hpb=a6244ba215ae16c32adce3b1c98468e007f3c582;p=hope.git diff --git a/src/hope_dictionary.erl b/src/hope_dictionary.erl new file mode 100644 index 0000000..2e3a59d --- /dev/null +++ b/src/hope_dictionary.erl @@ -0,0 +1,40 @@ +-module(hope_dictionary). + +-export_type( + [ t/2 + ]). + + +-type t(_Key, _Value) :: + term(). + + +-callback empty() -> + t(_K, _V). + +-callback get(t(K, V), K) -> + hope_option:t(V). + +-callback set(t(K, V), K, V) -> + t(K, V). + +-callback update(t(K, V), K, fun((hope_option:t(V)) -> V)) -> + t(K, V). + +-callback map(t(K, V), fun((K, V) -> V)) -> + t(K, V). + +-callback filter(t(K, V), fun((K, V) -> boolean())) -> + t(K, V). + +-callback fold(t(K, V), fun((K, V, Acc) -> Acc), Acc) -> + Acc. + +-callback iter(t(K, V), fun((K, V) -> ok)) -> + ok. + +-callback of_kv_list([{K, V}]) -> + t(K, V). + +-callback to_kv_list(t(K, V)) -> + [{K, V}].