Packages

Monads and other dark magic (monoids, functors, traversables, &c), forked by doma for maintenance and testing packagesets

Current section

3 Versions

Jump to

Compare versions

6 files changed
+36 additions
-53 deletions
  @@ -4,25 +4,26 @@
4 4 <<"Monads and other dark magic (monoids, functors, traversables, &c), forked by doma for maintenance and testing packagesets">>}.
5 5 {<<"elixir">>,<<"~> 1.9">>}.
6 6 {<<"files">>,
7 - [<<"lib">>,<<"lib/witchcraft.ex">>,<<"lib/witchcraft">>,
8 - <<"lib/witchcraft/ord.ex">>,<<"lib/witchcraft/semigroupoid.ex">>,
9 - <<"lib/witchcraft/traversable.ex">>,<<"lib/witchcraft/extend.ex">>,
10 - <<"lib/witchcraft/foldable">>,<<"lib/witchcraft/foldable/empty_error.ex">>,
11 - <<"lib/witchcraft/foldable/map.ex">>,<<"lib/witchcraft/foldable/list.ex">>,
7 + [<<"lib">>,<<"lib/witchcraft">>,<<"lib/witchcraft/extend.ex">>,
8 + <<"lib/witchcraft/chain.ex">>,<<"lib/witchcraft/foldable.ex">>,
9 + <<"lib/witchcraft/functor.ex">>,<<"lib/witchcraft/monad.ex">>,
10 + <<"lib/witchcraft/arrow.ex">>,<<"lib/witchcraft/foldable">>,
11 + <<"lib/witchcraft/foldable/empty_error.ex">>,
12 12 <<"lib/witchcraft/foldable/tuple.ex">>,
13 - <<"lib/witchcraft/foldable/bitstring.ex">>,<<"lib/witchcraft/apply.ex">>,
14 - <<"lib/witchcraft/internal.ex">>,<<"lib/witchcraft/bifunctor.ex">>,
15 - <<"lib/witchcraft/ord">>,<<"lib/witchcraft/ord/float.ex">>,
16 - <<"lib/witchcraft/ord/map.ex">>,<<"lib/witchcraft/ord/list.ex">>,
17 - <<"lib/witchcraft/ord/integer.ex">>,<<"lib/witchcraft/ord/tuple.ex">>,
18 - <<"lib/witchcraft/ord/bitstring.ex">>,<<"lib/witchcraft/setoid.ex">>,
19 - <<"lib/witchcraft/category.ex">>,<<"lib/witchcraft/comonad.ex">>,
20 - <<"lib/witchcraft/monoid.ex">>,<<"lib/witchcraft/semigroup.ex">>,
21 - <<"lib/witchcraft/foldable.ex">>,<<"lib/witchcraft/monad.ex">>,
22 - <<"lib/witchcraft/functor.ex">>,<<"lib/witchcraft/arrow.ex">>,
23 - <<"lib/witchcraft/applicative.ex">>,<<"lib/witchcraft/chain.ex">>,
24 - <<"lib/witchcraft/unit.ex">>,<<".formatter.exs">>,<<"mix.exs">>,
25 - <<"README.md">>,<<"LICENSE">>]}.
13 + <<"lib/witchcraft/foldable/list.ex">>,
14 + <<"lib/witchcraft/foldable/bitstring.ex">>,
15 + <<"lib/witchcraft/foldable/map.ex">>,<<"lib/witchcraft/semigroup.ex">>,
16 + <<"lib/witchcraft/applicative.ex">>,<<"lib/witchcraft/internal.ex">>,
17 + <<"lib/witchcraft/comonad.ex">>,<<"lib/witchcraft/bifunctor.ex">>,
18 + <<"lib/witchcraft/traversable.ex">>,<<"lib/witchcraft/ord.ex">>,
19 + <<"lib/witchcraft/monoid.ex">>,<<"lib/witchcraft/category.ex">>,
20 + <<"lib/witchcraft/apply.ex">>,<<"lib/witchcraft/semigroupoid.ex">>,
21 + <<"lib/witchcraft/setoid.ex">>,<<"lib/witchcraft/ord">>,
22 + <<"lib/witchcraft/ord/float.ex">>,<<"lib/witchcraft/ord/tuple.ex">>,
23 + <<"lib/witchcraft/ord/list.ex">>,<<"lib/witchcraft/ord/bitstring.ex">>,
24 + <<"lib/witchcraft/ord/integer.ex">>,<<"lib/witchcraft/ord/map.ex">>,
25 + <<"lib/witchcraft/unit.ex">>,<<"lib/witchcraft.ex">>,<<".formatter.exs">>,
26 + <<"mix.exs">>,<<"README.md">>,<<"LICENSE">>]}.
26 27 {<<"licenses">>,[<<"Apache-2.0">>]}.
27 28 {<<"links">>,
28 29 [{<<"Github">>,<<"https://github.com/doma-engineering/witchcraft">>},
  @@ -43,10 +44,10 @@
43 44 {<<"name">>,<<"doma_quark">>},
44 45 {<<"optional">>,false},
45 46 {<<"repository">>,<<"hexpm">>},
46 - {<<"requirement">>,<<"~> 2.3.2-doma2">>}],
47 + {<<"requirement">>,<<"~> 2.3.3-doma">>}],
47 48 [{<<"app">>,<<"doma_type_class">>},
48 49 {<<"name">>,<<"doma_type_class">>},
49 50 {<<"optional">>,false},
50 51 {<<"repository">>,<<"hexpm">>},
51 - {<<"requirement">>,<<"~> 1.2.10-blazing">>}]]}.
52 - {<<"version">>,<<"1.0.5-doma">>}.
52 + {<<"requirement">>,<<"~> 1.2.11-blazing">>}]]}.
53 + {<<"version">>,<<"1.0.6-doma">>}.
  @@ -84,8 +84,8 @@ defclass Witchcraft.Arrow do
84 84 f = fn x -> "#{x}-#{x}" end
85 85 g = &inspect/1
86 86
87 - left = Arrow.arrowize(sample, f) <|> Arrow.arrowize(sample, g)
88 - right = Arrow.arrowize(sample, f <|> g)
87 + left = compose(Arrow.arrowize(sample, f), Arrow.arrowize(sample, g))
88 + right = Arrow.arrowize(sample, compose(f, g))
89 89
90 90 equal?(pipe(a, left), pipe(a, right))
91 91 end
  @@ -106,8 +106,8 @@ defclass Witchcraft.Arrow do
106 106 f = Arrow.arrowize(sample, fn x -> "#{x}-#{x}" end)
107 107 g = Arrow.arrowize(sample, &inspect/1)
108 108
109 - left = Witchcraft.Arrow.first(f <|> g)
110 - right = Witchcraft.Arrow.first(f) <|> Witchcraft.Arrow.first(g)
109 + left = Witchcraft.Arrow.first(compose(f, g))
110 + right = compose(Witchcraft.Arrow.first(f), Witchcraft.Arrow.first(g))
111 111
112 112 equal?(pipe(a, left), pipe(a, right))
113 113 end
  @@ -128,8 +128,8 @@ defclass Witchcraft.Arrow do
128 128 f = Arrow.arrowize(sample, fn x -> "#{x}-#{x}" end)
129 129 g = Arrow.arrowize(sample, &inspect/1)
130 130
131 - left = Witchcraft.Arrow.second(f <|> g)
132 - right = Witchcraft.Arrow.second(f) <|> Witchcraft.Arrow.second(g)
131 + left = Witchcraft.Arrow.second(compose(f, g))
132 + right = compose(Witchcraft.Arrow.second(f), Witchcraft.Arrow.second(g))
133 133
134 134 equal?(pipe(a, left), pipe(a, right))
135 135 end
  @@ -200,8 +200,8 @@ defclass Witchcraft.Arrow do
200 200 x = Arrow.arrowize(sample, Witchcraft.Arrow.product(&Quark.id/1, g))
201 201 y = Witchcraft.Arrow.first(f)
202 202
203 - left = x <|> y
204 - right = y <|> x
203 + left = compose(x, y)
204 + right = compose(y, x)
205 205
206 206 equal?(pipe(a, left), pipe(a, right))
207 207 end
  @@ -210,8 +210,6 @@ defclass Witchcraft.Chain do
210 210 @doc """
211 211 Compose link functions to create a new link function.
212 212
213 - Note that this runs the same direction as `<|>` ("the math way").
214 -
215 213 This is `pipe_compose_link/2` with arguments flipped.
216 214
217 215 ## Examples
  @@ -62,8 +62,8 @@ defclass Witchcraft.Extend do
62 62 arg2 = generate(monoid)
63 63 arg3 = generate(monoid)
64 64
65 - f = fn x -> x <|> fn a -> a <> a end end
66 - g = fn y -> y <|> fn b -> b <> b <> b end end
65 + f = fn x -> compose(x, fn a -> a <> a end) end
66 + g = fn y -> compose(y, fn b -> b <> b <> b end) end
67 67
68 68 left =
69 69 a
  @@ -79,22 +79,6 @@ defclass Witchcraft.Semigroupoid do
79 79 @spec pipe_compose(t(), t()) :: t()
80 80 def pipe_compose(b, a), do: compose(a, b)
81 81
82 - @doc """
83 - Composition operator "the math way". Alias for `compose/2`.
84 -
85 - ## Examples
86 -
87 - iex> times_ten_plus_one =
88 - ...> fn x -> x + 1 end
89 - ...> <|> fn y -> y * 10 end
90 - ...>
91 - ...> times_ten_plus_one.(5)
92 - 51
93 -
94 - """
95 - @spec t() <|> any() :: t()
96 - def g <|> f, do: compose(g, f)
97 -
98 82 @doc """
99 83 Composition operator "the pipe way". Alias for `pipe_compose/2`.
Loading more files…