<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Hi, I have a token definition like this:</div><div class=""><br class=""></div><font face="Courier" class="">:- type location<br class="">                   --->    pos(index::int, line::int, col::int).<br class=""><br class="">    % for ast detection later.<br class="">:- type token<br class="">                   --->    tk(location, string)<br class="">                   ;       '('(location) ; ')'(location)<br class="">                   ;       '['(location) ; ']'(location)<br class="">                   ;       '{'(location) ; '}'(location)<br class="">                   ;       c1(location, string) ; cn(location, string)<br class="">                   ;       s1(location, string) ; s2(location, string)<br class="">           .</font><div class=""><br class=""></div><div class="">Given the above, I have now realised that I can’t easily (?) access the location part of any particulr instance of the token type because it doesn’t have a name and thus no field reader will be generated. As I understand it, I would have to give a unique name.</div><div class=""><br class=""></div><div class="">I tried:</div><div class=""><br class=""></div><div class=""><div style="background-color: rgb(255, 255, 255); line-height: 22px;" class=""><div class=""><font color="#24292e" face="Courier" class=""><span style="caret-color: rgb(36, 41, 46); white-space: pre;" class="">    arg(Tok1, canonicalize, 0, Out),</span></font><br class=""></div><div class=""><font color="#24292e" class=""><span style="caret-color: rgb(36, 41, 46); white-space: pre;" class=""><br class=""></span></font></div><div class=""><font color="#24292e" class=""><span style="caret-color: rgb(36, 41, 46); white-space: pre;" class="">and was rewarded with this message from the compiler,</span></font></div><div class=""><font color="#24292e" class=""><span style="caret-color: rgb(36, 41, 46); white-space: pre;" class=""><br class=""></span></font></div><div class=""><font color="#24292e" face="Courier" class=""><span style="white-space: pre;" class="">repl.m:199: In clause for predicate `run_lex'/3:</span></font></div><div class=""><font color="#24292e" face="Courier" class=""><span style="white-space: pre;" class="">repl.m:199: in argument 1 of call to predicate `lexer.on_string'/4:</span></font></div><div class=""><font color="#24292e" face="Courier" class=""><span style="white-space: pre;" class="">repl.m:199: in argument 2 of functor `string.between/3’:</span></font></div><div class=""><font color="#24292e" face="Courier" class=""><span style="white-space: pre;" class="">repl.m:199: in unification of argument</span></font></div><div class=""><font color="#24292e" face="Courier" class=""><span style="white-space: pre;" class="">repl.m:199: and term `index(Out)’:</span></font></div><div class=""><font color="#24292e" face="Courier" class=""><span style="white-space: pre;" class="">repl.m:199: type error in argument of functor `index'/1.</span></font></div><div class=""><font color="#24292e" face="Courier" class=""><span style="white-space: pre;" class="">repl.m:199: Argument 1 (Out) has type `(some [ArgT] ArgT)’,</span></font></div><div class=""><font color="#24292e" face="Courier" class=""><span style="white-space: pre;" class="">repl.m:199: expected type was `lexer.location’.</span></font></div><div class=""><font color="#24292e" class=""><span style="white-space: pre;" class=""><br class=""></span></font></div><div class=""><font color="#24292e" class=""><span style="white-space: pre;" class="">Which is fair enough but how do I do it? That message is currently above my pay grade.</span></font></div><div class=""><span style="white-space: pre; color: rgb(36, 41, 46);" class="">Have I overlooked something blindingly obvious?</span></div><div class=""><span style="white-space: pre; color: rgb(36, 41, 46);" class=""><br class=""></span></div><div style="color: rgb(36, 41, 46); font-family: Courier, Menlo, Monaco, "Courier New", monospace, Menlo, Monaco, "Courier New", monospace; font-size: 12px; white-space: pre;" class=""></div></div></div></body></html>