You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importNormkey_opt_spec={:keys,coll_of(one_of(~w"a b c"a))}fun_opt_spec={:fun,spec(is_function(1))}opts_spec=coll_of(one_of([key_opt_spec,fun_opt_spec]))conform!([{:fun,fn_->"auto"end}],opts_spec)
crashes with:
** (Protocol.UndefinedError) protocol Enumerable not implemented for #Function<44.97283095/1 in :erl_eval.expr/5> of type Function, only anonymous functions of arity 2 are enumerable. This protocol is implemented for the following type(s): Ecto.Adapters.SQL.Stream, Postgrex.Stream, DBConnection.Stream, DBConnection.PrepareStream, Timex.Interval, Matrex, StreamData, HashSet, Range, Map, Function, List, Stream, Date.Range, HashDict, GenEvent.Stream, MapSet, File.Stream, IO.Stream
(elixir 1.10.4) lib/enum.ex:3731: Enumerable.Function.reduce/3
(elixir 1.10.4) lib/enum.ex:605: Enum.count/1
(norm 0.12.0) lib/norm/core/collection.ex:57: Norm.Conformer.Conformable.Norm.Core.Collection.check_counts/3
(norm 0.12.0) lib/norm/core/collection.ex:18: Norm.Conformer.Conformable.Norm.Core.Collection.conform/3
(elixir 1.10.4) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
(elixir 1.10.4) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
(norm 0.12.0) lib/norm/conformer.ex:99: Norm.Conformer.Conformable.Tuple.conform/3
(elixir 1.10.4) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
(norm 0.12.0) lib/norm/core/any_of.ex:18: Norm.Conformer.Conformable.Norm.Core.AnyOf.conform/3
(elixir 1.10.4) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
(norm 0.12.0) lib/norm/core/collection.ex:22: Norm.Conformer.Conformable.Norm.Core.Collection.conform/3
(norm 0.12.0) lib/norm.ex:62: Norm.conform!/2
Enumerable.impl_for/1 for (fn _ -> "auto" end) returns Enumerable.Function, which is good enough for your check_enumerable/3 in norm/lib/norm/core/collection.ex, but when you try to actually enumerate it it'll blow up in your face:
defimplEnumerable,for: Functiondodefcount(_function),do: {:error,__MODULE__}defmember?(_function,_value),do: {:error,__MODULE__}defslice(_function),do: {:error,__MODULE__}defreduce(function,acc,fun)whenis_function(function,2),do: function.(acc,fun)defreduce(function,_acc,_fun)doraiseProtocol.UndefinedError,protocol: @protocol,value: function,description: "only anonymous functions of arity 2 are enumerable"endend
Further up the stack, we're trying to enumerate the function because in lib/norm/conformer.ex:99 you're trying to do this:
Conformable.conform(spec,elem(input,i),path++[I])
… which, if you expand the arguments, is:
Norm.Conformer.Conformable.conform(#Norm.CollOf<#Norm.OneOf<[:a, :b, :c]>>,#Function<44.97283095/1 in :erl_eval.expr/5>,[0,1])
I lack the time to figure out why you're trying to conform the :fun to the spec of the :key. I'm going to have to just rip the @contract off for now, as it's preventing routine maintenance.
The text was updated successfully, but these errors were encountered:
crashes with:
Enumerable.impl_for/1
for(fn _ -> "auto" end)
returnsEnumerable.Function
, which is good enough for yourcheck_enumerable/3
innorm/lib/norm/core/collection.ex
, but when you try to actually enumerate it it'll blow up in your face:Further up the stack, we're trying to enumerate the function because in
lib/norm/conformer.ex:99
you're trying to do this:… which, if you expand the arguments, is:
I lack the time to figure out why you're trying to conform the
:fun
to the spec of the:key
. I'm going to have to just rip the@contract
off for now, as it's preventing routine maintenance.The text was updated successfully, but these errors were encountered: