       typedefs: %{String.t => Types.t},
       file_group: FileGroup.t
     }
-    defstruct absolute_path: nil,
+    defstruct path: nil,
     module: nil,
-    thrift_namespace: nil,
     namespaces: %{},
     structs: %{},
     services: %{},

    @type header :: Include.t | Namespace.t
    @type typedef :: {:typedef, Types.t, atom}
    @type definition :: Service.t | TEnum.t | Exception.t | Union.t | Struct.t | Constant.t | typedef
    @type model :: header | definition
    @type t :: %Schema{
      absolute_path: Path.t,
      module: String.t,
      thrift_namespace: String.t,
      namespaces: %{String.t => Namespace.t},
      structs: %{String.t => Struct.t},
      services: %{String.t => Service.t},

    file_group: nil

    @doc """
    Constructs a schema from header and definition lists.
    """
    @spec new(Path.t | nil, [header], [definition]) :: t
    def new(path, headers, defs) do
      schema = %Schema{path: path, module: module_name(path)}

      (headers ++ defs)
      |> Enum.reverse
      |> Enum.reduce(schema, &merge(&2, &1))
    end

    defp module_name(nil), do: nil

    defp module_name(path) when is_bitstring(path) do
      path
      |> Path.basename
      |> Path.rootname
      |> String.to_atom
    end

    @spec merge(t, header | definition) :: t
    defp merge(schema, %Include{} = inc) do
      %Schema{schema | includes: [inc | schema.includes]}
    end
