I'm writing to the core list because it seems to me a problem with the 

To teach myself, I've done this silly thing, mostly following the official 

defmodule NewTable do
  defstruct data: []
  @type t :: %__MODULE__{
    data: nonempty_list(any)

defimpl Enumerable, for: NewTable do
  def reduce(t, acc, fun) do
    Enum.reduce(t.data, acc, fun)
  def count(t) do
    {:ok, length(t.data)}
  def member?(t, x) do
    {:ok, Enum.member?(t.data, x)}

I know there is no point of implementing Enumerable for a list but this is 
just a learning exercise.
count and member work. 
The above reduce method does not work. Trying to use Enum.at, Enum.max, etc 
on that struct will give back several errors about anonymous functions 
which are not clear at all.
I've tried with current master also, I get a different set of errors and 
even something I really do not know how to interpret:

Enum.max(%NewTable{ data: [1,2]})
{:cont, {:cont, #Reference<>}}

I've tried to use  :lists.foldl(fun, acc, t.data) instead of 
Enum.reduce(t.data, acc, fun) but gets the same kind of error.

I'm thinking this may be a language issue because if the above code is 
totally broken, it seems to me, reading the docs that it should work, so 
maybe the docs are misleading? Or maybe I'm just too new and I'm using some 
old way of thinking?
And in any case the errors provided does not give a hint about the problem

You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to