Skip to content

Commit

Permalink
Just skip lookup if no where clause
Browse files Browse the repository at this point in the history
  • Loading branch information
expede committed Dec 31, 2016
1 parent 81f9631 commit 5bf14dd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
5 changes: 2 additions & 3 deletions lib/type_class.ex
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,8 @@ defmodule TypeClass do
for dependency <- unquote(class).__dependencies__ do
proto = Module.concat(Module.split(dependency) ++ ["Proto"])

case Code.ensure_loaded(proto) do
{:module, _name} -> Protocol.assert_impl!(proto, unquote datatype)
_ -> unquote(datatype) |> conforms(to: dependency) # Conform recursively
if Exceptional.Safe.safe(&Protocol.assert_protocol!/1).(proto) == :ok do
Protocol.assert_impl!(proto, unquote datatype)
end
end

Expand Down
2 changes: 2 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ defmodule TypeClass.Mixfile do
preferred_cli_env: [espec: :test],

deps: [
{:exceptional, "~> 2.1"},

{:credo, "~> 0.5", only: [:dev, :test]},
{:espec, "~> 1.2", only: :test},

Expand Down
5 changes: 3 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"earmark": {:hex, :earmark, "1.0.3", "89bdbaf2aca8bbb5c97d8b3b55c5dd0cff517ecc78d417e87f1d0982e514557b", [:mix], []},
"espec": {:hex, :espec, "1.2.1", "faf0b54502688401097d8cb36da3f9ba75f894a39bccc65e5ae7bffb1256f03e", [:mix], [{:meck, "~> 0.8.4", [hex: :meck, optional: false]}]},
"ex_doc": {:hex, :ex_doc, "0.14.5", "c0433c8117e948404d93ca69411dd575ec6be39b47802e81ca8d91017a0cf83c", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]},
"inch_ex": {:hex, :inch_ex, "0.5.5", "b63f57e281467bd3456461525fdbc9e158c8edbe603da6e3e4671befde796a3d", [], [{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, optional: false]}]},
"exceptional": {:hex, :exceptional, "2.1.0", "b3bc6c7041a242df9f7e18223649f3d66633827897138cf5f26c46c88b6925ae", [:mix], []},
"inch_ex": {:hex, :inch_ex, "0.5.5", "b63f57e281467bd3456461525fdbc9e158c8edbe603da6e3e4671befde796a3d", [:mix], [{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, optional: false]}]},
"meck": {:hex, :meck, "0.8.4", "59ca1cd971372aa223138efcf9b29475bde299e1953046a0c727184790ab1520", [:make, :rebar], []},
"poison": {:hex, :poison, "3.0.0", "625ebd64d33ae2e65201c2c14d6c85c27cc8b68f2d0dd37828fde9c6920dd131", [], []}}
"poison": {:hex, :poison, "3.0.0", "625ebd64d33ae2e65201c2c14d6c85c27cc8b68f2d0dd37828fde9c6920dd131", [:mix], []}}
11 changes: 5 additions & 6 deletions spec/type_class_spec.exs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ defmodule TypeClassSpec do
def fmap(enum, fun), do: Enum.map(enum, fun)
end

describe "underlying protocol" do
it "is fmappable" do
expect(Functor.Proto.fmap([1,2,3], fn x -> x + 1 end)) |> to(eql [2,3,4])
end
end
# describe "underlying protocol" do
# it "is fmappable" do
# expect(Functor.Proto.fmap([1,2,3], fn x -> x + 1 end)) |> to(eql [2,3,4])
# end
# end

describe "unified API (reexport)" do
it "is fmappable" do
alias Functor
expect(Functor.fmap([1,2,3], fn x -> x + 1 end)) |> to(eql [2,3,4])
end
end
Expand Down

0 comments on commit 5bf14dd

Please sign in to comment.