title: Swi-prolog Type error: `list' expected, found a compound
body: <p>Type error when I try to use the following code to concatenate strings.  The expected behavior is to generate the concatenation of the strings as <code>FName</code>.</p>
  
  <pre><code>make_file_name(Prefix, Extension, FName) :-
      ( atom(Prefix) -&gt;
            name(Prefix, PrefixStr)
      ; PrefixStr = Prefix
      ),
      ( atom(Extension) -&gt;
            name(Extension, ExtensionStr)
      ; ExtensionStr = Extension
      ),
      append(PrefixStr, ExtensionStr, FNameStr),
      name(FName, FNameStr).
  </code></pre>
  
  <p>The error can be generated like following:</p>
  
  <pre><code>➜  chill git:(master) ✗ swipl                                                     [18/06/18| 4:23PM]
  Welcome to SWI-Prolog (threaded, 64 bits, version 7.6.4)
  SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
  Please run ?- license. for legal details.
  
  For online help and background, visit http://www.swi-prolog.org
  For built-in help, use ?- help(Topic). or ?- apropos(Word).
  
  ?- consult('test_name.pl')
  |    .
  true.
  
  ?- make_file_name('orig-db', "-parser.pl", TestProg).
  ERROR: Type error: `list' expected, found `[111,114,105,103,45,100,98|"-parser.pl"]' (a compound)
  ERROR: In:
  ERROR:    [9] name(_3402,[111,114|...])
  ERROR:    [7] &lt;user&gt;
  ERROR: 
  ERROR: Note: some frames are missing due to last-call optimization.
  ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
  </code></pre>
  
  <p>From the error info, it's easy to guess that string <code>orig-db</code> is converted to the <code>ASCII</code> list.</p>
  
  <p>I can offer a test using <code>yap</code> prolog, it's also confusing.</p>
  
  <pre><code>➜  chill git:(master) ✗ yap                                                      [18/06/18| 4:03PM]
  % Restoring file /usr/lib/Yap/startup.yss
  YAP 6.2.2 (x86_64-linux): Sat Sep 17 13:59:03 UTC 2016
     ?- [user].
   % consulting user_input...
  | make_file_name(Prefix, Extension, FName) :-
  | ( atom(Prefix) -&gt;
  |       name(Prefix, PrefixStr)
  | ; PrefixStr = Prefix
  | ),
  | ( atom(Extension) -&gt;
  |       name(Extension, ExtensionStr)
  | ; ExtensionStr = Extension
  | ),
  | append(PrefixStr, ExtensionStr, FNameStr),
  | name(FName, FNameStr).
  | 
   % consulted user_input in module user, 1 msec 9536 bytes
  yes
     ?- make_file_name('orig-db', "-parser.pl", TestProg).
  no
  </code></pre>
  
  <p>Hope somebody can help with the case. I am new to <code>prolog</code> and would like to learn more.</p>
  
  <p>Thank you!</p>
  
  <hr>
  
  <p><em>I am trying to migrate an earlier code to <code>SWI-Prolog</code>, which was written in
  <code>SICStus 3 #3: Thu Sep 12 09:54:27 CDT 1996</code> or earlier
  by Raymond J. Mooney <a href="ftp://ftp.cs.utexas.edu/pub/mooney/chill/" rel="nofollow noreferrer">ftp://ftp.cs.utexas.edu/pub/mooney/chill/</a>. 
  All the questions with this tag are all related to this task. I'm new to prolog, helps and suggestions are welcomed!</em></p>