Why does compiling this code:
triples( [], _,_,_)->
[];
triples( Self, X, Y, none )->
[ Result || Result = { X, Y, _} <- Self ].
This is because variables occurring on the LHS of generators, X and Y here, are always new unbound variables local to the comprehension. This means that they are not the same variables as the X and Y in the head of triples and, therefore, there is no implicit equality test. This similar to funs where all variables occurring in the head of a fun are alse new variables local to the fun.
This is different from most of the rest of erlang, which is why the compiler not only warns that the X and Y in the head are not used but also that the X and Y in the comprehension shadow the other variables. They are also unused anywhere in the comprehension.
An easy way to get what you want is:
[ Result || Result = {X1,Y1,_} <- Self, X =:= X1, Y =:= Y1 ]