-module(parser_gleam@stream). -compile(no_auto_import). -export([stream/2, get/1, at_end/1, get_and_next/1, get_eq/1]). -export_type([stream/1, it_and_next/1]). -type stream(FBA) :: {stream, list(FBA), integer()}. -type it_and_next(FBB) :: {it_and_next, FBB, stream(FBB)}. -spec stream(list(FBE), gleam@option:option(integer())) -> stream(FBE). stream(Buffer, Cursor) -> {stream, Buffer, begin _pipe = Cursor, gleam@option:unwrap(_pipe, 0) end}. -spec get(stream(FBI)) -> gleam@option:option(FBI). get(S) -> _pipe = erlang:element(2, S), _pipe@1 = gleam@list:at(_pipe, erlang:element(3, S)), gleam@option:from_result(_pipe@1). -spec at_end(stream(any())) -> boolean(). at_end(S) -> erlang:element(3, S) >= gleam@list:length(erlang:element(2, S)). -spec get_and_next(stream(FBP)) -> gleam@option:option(it_and_next(FBP)). get_and_next(S) -> _pipe = get(S), gleam@option:map( _pipe, fun(Value) -> {it_and_next, Value, {stream, erlang:element(2, S), erlang:element(3, S) + 1}} end ). -spec get_eq(fp_gl@eq:eq(FBT)) -> fp_gl@eq:eq(stream(FBT)). get_eq(E) -> fp_gl@eq:from_equals( fun(X, Y) -> Ea = fp_gl@flist:get_eq(E), (erlang:element(3, X) =:= erlang:element(3, Y)) andalso (erlang:element(2, Ea))( erlang:element(2, X), erlang:element(2, Y) ) end ).