Current section
Files
Jump to
Current section
Files
src/lamb@query.erl
-module(lamb@query).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([new/0, index/2, record/2, map/2, validate/1]).
-export_type([test/1]).
-type test(GIX) :: no_match |
{spec, GIX} |
{invalid, list(gleam@erlang@charlist:charlist())}.
-file("/Users/chouzar/Bench/Projects/lamb/src/lamb/query.gleam", 18).
-spec new() -> {{gleam@erlang@atom:atom_(), gleam@erlang@atom:atom_()},
list(nil),
list(gleam@erlang@atom:atom_())}.
new() ->
Head = {lamb@query@term:any(), lamb@query@term:any()},
Body = lamb@query@term:records(),
{Head, [], [Body]}.
-file("/Users/chouzar/Bench/Projects/lamb/src/lamb/query.gleam", 24).
-spec index({{any(), GJN}, list(nil), list(GJO)}, GJS) -> {{GJS, GJN},
list(nil),
list(GJO)}.
index(Query, Spec) ->
{{_, Record}, Conditions, Body} = Query,
Head = {Spec, Record},
{Head, Conditions, Body}.
-file("/Users/chouzar/Bench/Projects/lamb/src/lamb/query.gleam", 30).
-spec record({{GJW, any()}, list(nil), list(GJY)}, GKC) -> {{GJW, GKC},
list(nil),
list(GJY)}.
record(Query, Spec) ->
{{Index, _}, Conditions, Body} = Query,
Head = {Index, Spec},
{Head, Conditions, Body}.
-file("/Users/chouzar/Bench/Projects/lamb/src/lamb/query.gleam", 36).
-spec map({{GKG, GKH}, list(nil), list(any())}, fun((GKG, GKH) -> GKM)) -> {{GKG,
GKH},
list(nil),
list(GKM)}.
map(Query, Mapper) ->
{Head, Conditions, _} = Query,
{Index, Record} = Head,
Spec = begin
_pipe = Mapper(Index, Record),
lamb_erlang_ffi:wrap_tuple(_pipe)
end,
{Head, Conditions, [Spec]}.
-file("/Users/chouzar/Bench/Projects/lamb/src/lamb/query.gleam", 57).
-spec validate({{GKS, GKT}, list(nil), list(GKU)}) -> {ok,
{{GKS, GKT}, list(nil), list(GKU)}} |
{error, list(binary())}.
validate(Query) ->
case lamb_erlang_ffi:test_query(Query, {lamb@query@term:any()}) of
no_match ->
{ok, Query};
{spec, _} ->
{ok, Query};
{invalid, Errors} ->
{error, gleam@list:map(Errors, fun unicode:characters_to_binary/1)}
end.