Current section

Files

Jump to
datum src t.erl
Raw

src/t.erl

-module(t).
-compile({parse_transform, generic}).
-export([t/0, iri/0]).
-record(adt, {a, b, c}).
t() ->
Struct = #{<<"a">> => 1, <<"b">> => <<"test@org">>, <<"c">> => 2.0},
Lens = labelled:lens(
#adt{
b = iri()
}
),
lens:get(Lens, Struct).
iri() ->
fun(Fun, IRI) ->
lens:fmap(fun(X) -> X end, Fun(iri(IRI)))
end.
iri(IRI) ->
[Suffix, Prefix] = binary:split(IRI, <<$@>>),
{iri, Prefix, Suffix}.