================================================================================
External functions
================================================================================

external fn read_file(String) -> Result(String, Reason) =
  "file" "open"
external fn a(name: String) -> String = "x" "y"
external fn a() -> #(List(Int), fn(Int) -> String) = "x" "y"

--------------------------------------------------------------------------------

(source_file
  (external_function
    name: (identifier)
    parameters: (function_parameters
      (function_parameter
        type: (type
          name: (type_identifier))))
    return_type: (type
      name: (type_identifier)
      arguments: (type_arguments
        (type_argument
          (type
            name: (type_identifier)))
        (type_argument
          (type
            name: (type_identifier)))))
    body: (external_function_body
      (string
        (quoted_content))
      (string
        (quoted_content))))
  (external_function
    name: (identifier)
    parameters: (function_parameters
      (function_parameter
        name: (identifier)
        type: (type
          name: (type_identifier))))
    return_type: (type
      name: (type_identifier))
    body: (external_function_body
      (string
        (quoted_content))
      (string
        (quoted_content))))
  (external_function
    name: (identifier)
    parameters: (function_parameters)
    return_type: (tuple_type
      (type
        name: (type_identifier)
        arguments: (type_arguments
          (type_argument
            (type
              name: (type_identifier)))))
      (function_type
        parameter_types: (function_parameter_types
          (type
            name: (type_identifier)))
        return_type: (type
          name: (type_identifier))))
    body: (external_function_body
      (string
        (quoted_content))
      (string
        (quoted_content)))))

================================================================================
Public external functions
================================================================================

pub external fn read_file(String) -> Result(String, Reason) =
  "file" "open"
pub external fn a(name: String) -> String = "x" "y"
pub external fn a() -> #(List(Int), fn(Int) -> String) = "x" "y"

--------------------------------------------------------------------------------

(source_file
  (external_function
    (visibility_modifier)
    name: (identifier)
    parameters: (function_parameters
      (function_parameter
        type: (type
          name: (type_identifier))))
    return_type: (type
      name: (type_identifier)
      arguments: (type_arguments
        (type_argument
          (type
            name: (type_identifier)))
        (type_argument
          (type
            name: (type_identifier)))))
    body: (external_function_body
      (string
        (quoted_content))
      (string
        (quoted_content))))
  (external_function
    (visibility_modifier)
    name: (identifier)
    parameters: (function_parameters
      (function_parameter
        name: (identifier)
        type: (type
          name: (type_identifier))))
    return_type: (type
      name: (type_identifier))
    body: (external_function_body
      (string
        (quoted_content))
      (string
        (quoted_content))))
  (external_function
    (visibility_modifier)
    name: (identifier)
    parameters: (function_parameters)
    return_type: (tuple_type
      (type
        name: (type_identifier)
        arguments: (type_arguments
          (type_argument
            (type
              name: (type_identifier)))))
      (function_type
        parameter_types: (function_parameter_types
          (type
            name: (type_identifier)))
        return_type: (type
          name: (type_identifier))))
    body: (external_function_body
      (string
        (quoted_content))
      (string
        (quoted_content)))))

================================================================================
External function with attribute syntax
================================================================================

@external(erlang, "erlang", "integer_to_list")
fn integer_to_list(int int: Int, base base: Int) -> String

---

(source_file
  (attribute
    (identifier)
    (arguments
      (attribute_value
        (identifier))
      (attribute_value
        (string
          (quoted_content)))
      (attribute_value
        (string
          (quoted_content)))))
  (function
    (identifier)
    (function_parameters
      (function_parameter
        (label)
        (identifier)
        (type
          (type_identifier)))
      (function_parameter
        (label)
        (identifier)
        (type
          (type_identifier))))
    (type
      (type_identifier))))
