Skip to content

Commit

Permalink
Merge pull request witchcrafters#74 from witchcrafters/quinn/1.3.1
Browse files Browse the repository at this point in the history
Maintenance + bump to 1.3.1
  • Loading branch information
QuinnWilton authored Jan 30, 2022
2 parents a539d83 + 4b901dc commit 8e9e248
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 44 deletions.
File renamed without changes.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ erl_crash.dump
*.ez
*.beam
.DS_Store
mix.lock
.mix
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 22.0.5
elixir 1.9.4
erlang 24.2
elixir 1.13.2
30 changes: 0 additions & 30 deletions config/config.exs

This file was deleted.

16 changes: 8 additions & 8 deletions lib/algae/reader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ defmodule Algae.Reader do
iex> use Witchcraft
...>
...> correct =
iex> correct =
...> monad %Algae.Reader{} do
...> count <- ask &Map.get(&1, :count)
...> bindings <- ask()
...> return (count == Map.size(bindings))
...> return (count == map_size(bindings))
...> end
...>
...> sample_bindings = %{count: 3, a: 1, b: 2}
...> correct_count = run(correct, sample_bindings)
...> "Correct count for #{inspect sample_bindings}? #{correct_count}"
iex> sample_bindings = %{count: 3, a: 1, b: 2}
iex> correct_count = run(correct, sample_bindings)
iex> "Correct count for #{inspect sample_bindings}? #{correct_count}"
"Correct count for %{a: 1, b: 2, count: 3}? true"
...>
...> bad_bindings = %{count: 100, a: 1, b: 2}
...> bad_count = run(correct, bad_bindings)
...> "Correct count for #{inspect bad_bindings}? #{bad_count}"
iex> bad_bindings = %{count: 100, a: 1, b: 2}
iex> bad_count = run(correct, bad_bindings)
iex> "Correct count for #{inspect bad_bindings}? #{bad_count}"
"Correct count for %{a: 1, b: 2, count: 100}? false"
Example adapted from
Expand Down
2 changes: 1 addition & 1 deletion lib/algae/state.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ defmodule Algae.State do
defstruct [runner: &State.default/1]

@spec default(any()) :: {integer(), any()}
defp default(s), do: {s, s}
def default(s), do: {s, s}

@doc """
Construct a new `Algae.State` struct from a state runner in the form
Expand Down
7 changes: 6 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ defmodule Algae.Mixfile do
app: :algae,
aliases: aliases(),
deps: deps(),
preferred_cli_env: [quality: :test],

# Versions
version: "1.3.0",
version: "1.3.1",
elixir: "~> 1.9",
elixirc_paths: elixirc_paths(Mix.env()),

# Docs
name: "Algae",
Expand All @@ -30,6 +32,9 @@ defmodule Algae.Mixfile do
]
end

defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]

defp deps do
[
{:credo, "~> 1.5", only: [:dev, :test], runtime: false},
Expand Down
21 changes: 21 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
%{
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"credo": {:hex, :credo, "1.6.2", "2f82b29a47c0bb7b72f023bf3a34d151624f1cbe1e6c4e52303b05a11166a701", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "ae9dc112bc368e7b145c547bec2ed257ef88955851c15057c7835251a17211c6"},
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"earmark": {:hex, :earmark, "1.4.20", "d5097b1c7417a03c73a2985fcf01c3f72192c427b8a498719737dca5273938cb", [:mix], [{:earmark_parser, "== 1.4.18", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "7be744242dbde74c858279f4a65d9d31f37d163190d739340015c30038c1edb3"},
"earmark_parser": {:hex, :earmark_parser, "1.4.18", "e1b2be73eb08a49fb032a0208bf647380682374a725dfb5b9e510def8397f6f2", [:mix], [], "hexpm", "114a0e85ec3cf9e04b811009e73c206394ffecfcc313e0b346de0d557774ee97"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.26.0", "1922164bac0b18b02f84d6f69cab1b93bc3e870e2ad18d5dacb50a9e06b542a3", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2775d66e494a9a48355db7867478ffd997864c61c65a47d31c4949459281c78d"},
"exceptional": {:hex, :exceptional, "2.1.3", "cb17cb9b7c4882e763b82db08ba317678157ca95970fae96b31b3c90f5960c3d", [:mix], [], "hexpm", "59d67ae2df6784e7a957087742ae9011f220c3d1523706c5cd7ee0741bca5897"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"inch_ex": {:hex, :inch_ex, "2.0.0", "24268a9284a1751f2ceda569cd978e1fa394c977c45c331bb52a405de544f4de", [:mix], [{:bunt, "~> 0.2", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "96d0ec5ecac8cf63142d02f16b7ab7152cf0f0f1a185a80161b758383c9399a8"},
"jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.1", "264fc6864936b59fedb3ceb89998c64e9bb91945faf1eb115d349b96913cc2ef", [:mix], [], "hexpm", "23c31d0ec38c97bf9adde35bc91bc8e1181ea5202881f48a192f4aa2d2cf4d59"},
"operator": {:hex, :operator, "0.2.1", "4572312bbd3e63a5c237bf15c3a7670d568e3651ea744289130780006e70e5f5", [:mix], [], "hexpm", "1990cc6dc651d7fff04636eef06fc64e6bc1da83a1da890c08ca3432e17e267a"},
"quark": {:hex, :quark, "2.3.2", "066e0d431440d077684469967f54d732443ea2a48932e0916e974633e8b39c95", [:mix], [], "hexpm", "2f6423779b02afe7e3e4af3cfecfcd94572f2051664d4d8329ffa872d24b10a8"},
"type_class": {:hex, :type_class, "1.2.8", "349db84be8c664e119efaae1a09a44b113bc8e81af1d032f4e3e38feef4fac32", [:mix], [{:exceptional, "~> 2.1", [hex: :exceptional, repo: "hexpm", optional: false]}], "hexpm", "bb93de2cacfd6f0ee43f4616f7a139816a73deba4ae8ee3364bcfa4abe3eef3e"},
"witchcraft": {:hex, :witchcraft, "1.0.4", "8733ac0ee769d4d2f73610de5a2b601a4ccbe385d1fca6419280f2511d21d0c9", [:mix], [{:exceptional, "~> 2.1", [hex: :exceptional, repo: "hexpm", optional: false]}, {:operator, "~> 0.2", [hex: :operator, repo: "hexpm", optional: false]}, {:quark, "~> 2.2", [hex: :quark, repo: "hexpm", optional: false]}, {:type_class, "~> 1.2", [hex: :type_class, repo: "hexpm", optional: false]}], "hexpm", "a380f439f1962d2e56cdad874ed7eb4612ddd6ec5ee3c6ad0c5d63e60539e6b0"},
}
32 changes: 32 additions & 0 deletions test/support.exs → test/support/example.ex
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import Algae

defmodule Example do
@moduledoc false

defdata Complex :: ([{:ok, integer()}] | number()) \\ 22

defdata Any :: any()
defdata Int :: integer()
defdata None :: none()

defmodule Embedded.One do
@moduledoc false

defdata do: quux :: any() \\ 22
end

defmodule Embedded.Many do
@moduledoc false

defdata do
first :: any()
second :: integer() \\ 42
Expand All @@ -25,10 +31,14 @@ defmodule Example do
end

defmodule Simple do
@moduledoc false

defdata any()
end

defmodule Sum.Lights do
@moduledoc false

defsum do
defdata Red :: any() \\ 22
defdata Yellow :: any()
Expand All @@ -37,6 +47,8 @@ defmodule Example do
end

defmodule Sum.Maybe do
@moduledoc false

defsum do
defdata Just do
value :: any()
Expand All @@ -47,6 +59,8 @@ defmodule Example do
end

defmodule Player do
@moduledoc false

# =============== #
# Data Definition #
# =============== #
Expand All @@ -72,19 +86,25 @@ defmodule Example do
end

defmodule Id do
@moduledoc false

defdata any()
end

defdata Wrapper :: any()

defmodule Person do
@moduledoc false

defdata do
name :: String.t()
age :: non_neg_integer()
end
end

defmodule Animal do
@moduledoc false

defdata do
name :: String.t()
leg_count :: non_neg_integer() \\ 4
Expand All @@ -96,16 +116,22 @@ defmodule Example do
end

defmodule Constant do
@moduledoc false

defdata fun()

def new(value), do: %Constant{constant: fn _ -> value end}
end

defmodule Nothing do
@moduledoc false

defdata none()
end

defmodule Light do
@moduledoc false

# ============== #
# Sum Definition #
# ============== #
Expand All @@ -127,6 +153,8 @@ defmodule Example do
end

defmodule Pet do
@moduledoc false

defsum do
defdata Cat do
name :: String.t()
Expand All @@ -141,6 +169,8 @@ defmodule Example do
end

defmodule Option do
@moduledoc false

defsum do
defdata None :: none()
defdata Some :: any()
Expand All @@ -151,6 +181,8 @@ defmodule Example do
defdata Video :: String.t() \\ "2001: A Space Odyssey"

defmodule Media do
@moduledoc false

defsum do
defdata Paper :: Example.Book.t() \\ Example.Book.new()
defdata Film :: Example.Video.t() \\ Example.Video.new("A Clockwork Orange")
Expand Down
1 change: 0 additions & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ExUnit.start()
Code.load_file("test/support.exs")

0 comments on commit 8e9e248

Please sign in to comment.