From a547862576bd28bc4d43ed47d4df08564d1dd0a1 Mon Sep 17 00:00:00 2001 From: Brooklyn Zelenka Date: Mon, 12 Sep 2016 21:24:28 +0900 Subject: [PATCH] Ignore doc/ --- .gitignore | 1 + doc/.build | 34 ++ doc/404.html | 47 +- doc/Witchcraft.Applicative.Function.html | 252 +++++++--- doc/Witchcraft.Applicative.Operator.html | 85 ++-- doc/Witchcraft.Applicative.Property.html | 133 ++--- doc/Witchcraft.Applicative.Protocol.html | 260 ++++++++++ doc/Witchcraft.Applicative.Wrap.html | 183 +++++++ doc/Witchcraft.Applicative.html | 424 ++++++++++++---- doc/Witchcraft.Functor.Function.html | 102 ++-- doc/Witchcraft.Functor.Operator.html | 89 ++-- doc/Witchcraft.Functor.Property.html | 99 ++-- doc/Witchcraft.Functor.Protocol.html | 219 +++++++++ doc/Witchcraft.Functor.html | 301 ++++++++---- doc/Witchcraft.Monad.Function.html | 98 ++-- doc/Witchcraft.Monad.Operator.html | 138 ++++-- doc/Witchcraft.Monad.Property.html | 237 +++++++++ doc/Witchcraft.Monad.Protocol.html | 227 +++++++++ doc/Witchcraft.Monad.html | 223 ++++++--- doc/Witchcraft.Monoid.Identity.html | 183 +++++++ doc/Witchcraft.Monoid.Operator.html | 99 ++-- doc/Witchcraft.Monoid.Property.html | 98 ++-- doc/Witchcraft.Monoid.Protocol.html | 256 ++++++++++ doc/Witchcraft.Monoid.html | 191 ++++--- doc/Witchcraft.Sad.html | 53 +- doc/Witchcraft.html | 602 ++--------------------- doc/api-reference.html | 145 ++++-- doc/dist/app-6d2e071366.js | 6 - doc/dist/app-7e84850c37.css | 1 + doc/dist/app-95540a96e6.js | 6 + doc/dist/app-ddd9717ad9.css | 1 - doc/dist/sidebar_items.js | 2 +- doc/index.html | 6 +- doc/readme.html | 108 ++-- 34 files changed, 3362 insertions(+), 1547 deletions(-) create mode 100644 doc/.build create mode 100644 doc/Witchcraft.Applicative.Protocol.html create mode 100644 doc/Witchcraft.Applicative.Wrap.html create mode 100644 doc/Witchcraft.Functor.Protocol.html create mode 100644 doc/Witchcraft.Monad.Property.html create mode 100644 doc/Witchcraft.Monad.Protocol.html create mode 100644 doc/Witchcraft.Monoid.Identity.html create mode 100644 doc/Witchcraft.Monoid.Protocol.html delete mode 100644 doc/dist/app-6d2e071366.js create mode 100644 doc/dist/app-7e84850c37.css create mode 100644 doc/dist/app-95540a96e6.js delete mode 100644 doc/dist/app-ddd9717ad9.css diff --git a/.gitignore b/.gitignore index 6e41e8b..a30b9e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /_build /cover /deps +/docs erl_crash.dump *.ez *.beam diff --git a/doc/.build b/doc/.build new file mode 100644 index 0000000..84e49d3 --- /dev/null +++ b/doc/.build @@ -0,0 +1,34 @@ +index.html +readme.html +404.html +dist/sidebar_items.js +Witchcraft.html +Witchcraft.Applicative.html +Witchcraft.Applicative.Function.html +Witchcraft.Applicative.Operator.html +Witchcraft.Applicative.Property.html +Witchcraft.Applicative.Wrap.html +Witchcraft.Functor.html +Witchcraft.Functor.Function.html +Witchcraft.Functor.Operator.html +Witchcraft.Functor.Property.html +Witchcraft.Monad.html +Witchcraft.Monad.Function.html +Witchcraft.Monad.Operator.html +Witchcraft.Monad.Property.html +Witchcraft.Monoid.html +Witchcraft.Monoid.Identity.html +Witchcraft.Monoid.Operator.html +Witchcraft.Monoid.Property.html +Witchcraft.Sad.html +Witchcraft.Applicative.Protocol.html +Witchcraft.Functor.Protocol.html +Witchcraft.Monad.Protocol.html +Witchcraft.Monoid.Protocol.html +dist/app-7e84850c37.css +dist/app-95540a96e6.js +fonts/icomoon.eot +fonts/icomoon.svg +fonts/icomoon.ttf +fonts/icomoon.woff +api-reference.html diff --git a/doc/404.html b/doc/404.html index ff7c76f..9d94c09 100644 --- a/doc/404.html +++ b/doc/404.html @@ -4,30 +4,31 @@ - - 404 – Witchcraft v0.4.2 - + + 404 – Witchcraft v0.5.0 + + + + +
-
+
+

Page not found

@@ -69,23 +71,24 @@

Page not found

API Reference page to find what you were looking for.

- +
- + diff --git a/doc/Witchcraft.Applicative.Function.html b/doc/Witchcraft.Applicative.Function.html index 7c936ba..2d0ec2e 100644 --- a/doc/Witchcraft.Applicative.Function.html +++ b/doc/Witchcraft.Applicative.Function.html @@ -4,30 +4,31 @@ - - Witchcraft.Applicative.Function – Witchcraft v0.4.2 - + + Witchcraft.Applicative.Function – Witchcraft v0.5.0 + + + + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Applicative.Function - +

-
-

Function helpers, derivatives and operators for Witchcraft.Applicative

+
+

Function helpers, derivatives and operators for +Witchcraft.Applicative.Protocol

@@ -89,6 +92,19 @@

Summary

+
+

+ Types +

+
+ + +
+ +
+
@@ -97,16 +113,40 @@

+ +

lift a function over 2 arguments

+
+ +
+
+ + +

lift a function over 3 arguments

+
+ +
+
+ -

lift a function that takes a list of arguments

+

lift a function over 4 arguments

+
+

Sequentially seq, and discard the second value of each pair

@@ -115,7 +155,7 @@

Sequentially seq, and discard the first value of each pair

@@ -134,6 +174,22 @@

+
+

+ + + + Types +

+
+
+
applicative :: any
+ +
+ +
+
+
@@ -143,61 +199,141 @@

Functions

-
+
- + - lift(list, fun) - - + lift(val_1, val_2, fun) + + + + + + +
+ +
+

Specs

+
+ +
lift(applicative, applicative, (... -> any)) :: applicative
+ +
lift(applicative, applicative, (... -> any)) :: applicative
+ +
+
+ +
+

lift a function over 2 arguments

+

+ + Examples +

+ +
iex> lift([1,2,3], [4,5,6], &(&1 + &2))
+[5,6,7,6,7,8,7,8,9]
+ +
+
+
+
+ + + + lift(val_1, val_2, val_3, fun) + + +

Specs

-
lift(any, (... -> any)) :: any
+
lift(applicative, applicative, applicative, (... -> any)) :: applicative
-

lift a function that takes a list of arguments

-

-iex> lift([[1,2,3], [4,5,6]], &(&1 + &2))
-[5,6,7,6,7,8,7,8,9]
+    

lift a function over 3 arguments

+

+ + Examples +

-iex> lift([[1,2], [3,4], [5,6]], &(&1 + &2 + &3)) -[9,10,10,11,10,11,11,12] +
iex> lift([1,2], [3,4], [5,6], &(&1 + &2 + &3))
+[9,10,10,11,10,11,11,12]
-iex> lift([[1,2], [3,4], [5,6], [7,8]], &(&1 + &2 + &3 + &4)) -[16,17,17,18,17,18,18,19,17,18,18,19,18,19,19,20] -
+
+
+
+
+ + + + lift(val_1, val_2, val_3, val_4, fun) + + + + + + +
+ +
+

lift a function over 4 arguments

+

+ + Examples +

+ +
iex> lift([1,2], [3,4], [5,6], [7,8], &(&1 + &2 + &3 + &4))
+[16,17,17,18,17,18,18,19,17,18,18,19,18,19,19,20]
-
+
- + - seq_first(list) - - + rewrap(pre_wrapped) + + + +
+ +
+ +
+
+
+
+ + + + seq_first(first, second) + + + + + +

Specs

-
seq_first([any]) :: any
+
seq_first(applicative, applicative) :: any
@@ -207,24 +343,25 @@

Specs

-
+

Specs

-
seq_second([any]) :: any
+
seq_second(applicative, applicative) :: any
@@ -241,23 +378,24 @@

Specs

- +
- + diff --git a/doc/Witchcraft.Applicative.Operator.html b/doc/Witchcraft.Applicative.Operator.html index fa81f0f..35a741c 100644 --- a/doc/Witchcraft.Applicative.Operator.html +++ b/doc/Witchcraft.Applicative.Operator.html @@ -4,30 +4,31 @@ - - Witchcraft.Applicative.Operator – Witchcraft v0.4.2 - + + Witchcraft.Applicative.Operator – Witchcraft v0.5.0 + + + + +
-
+
+
@@ -160,14 +163,17 @@

Specs

Infix alias for Witchcraft.Applicative.seq, with arguments reversed.

This version is preferred, as it makes chaining arguments along wrapped partial applications clearer when reading left-to-right.

-

-iex> [&(&1 + 1), &(&1 * 10)] <<~ [1,2,3]
+

+ + Examples +

+ +
iex> [&(&1 + 1), &(&1 * 10)] <<~ [1,2,3]
 [2,3,4,10,20,30]
 
 iex> import Witchcraft.Functor.Operator, only: [<~: 2]
 iex> (&(fn x -> x * &1 end)) <~ [1,2,3] <<~ [9,10,11]
-[9,10,11,18,20,22,27,30,33]
-
+[9,10,11,18,20,22,27,30,33]
@@ -177,11 +183,12 @@

Specs

value ~>> func - - + + +
@@ -196,14 +203,17 @@

Specs

Infix alias for Witchcraft.Applicative.seq. If chaining, be sure to wrap each layer in parentheses, as ~>> and ~> are left associative.

-

-iex> [1,2,3] ~>> [&(&1 + 1), &(&1 * 10)]
+

+ + Examples +

+ +
iex> [1,2,3] ~>> [&(&1 + 1), &(&1 * 10)]
 [2,3,4,10,20,30]
 
 iex> import Witchcraft.Functor.Operator, only: [~>: 2]
 iex> [9, 10] ~>> ([1,2,3] ~> &(fn x -> x * &1 end))
-[9, 10, 18, 20, 27, 30]
-
+[9, 10, 18, 20, 27, 30]
@@ -214,23 +224,24 @@

Specs

- +
- + diff --git a/doc/Witchcraft.Applicative.Property.html b/doc/Witchcraft.Applicative.Property.html index 2737183..e69acb0 100644 --- a/doc/Witchcraft.Applicative.Property.html +++ b/doc/Witchcraft.Applicative.Property.html @@ -4,30 +4,31 @@ - - Witchcraft.Applicative.Property – Witchcraft v0.4.2 - + + Witchcraft.Applicative.Property – Witchcraft v0.5.0 + + + + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Applicative.Property - +

-
+

Check samples of your applicative functor to confirm that your data adheres to the applicative properties. All members of your datatype should adhere to these rules, plus implement Witchcraft.Functor.

@@ -172,11 +174,12 @@

spotcheck_composition(value, fun1, fun2) - - + + +

@@ -190,8 +193,13 @@

Specs

seq composes normally.

-

iex> spotcheck_composition([1, 2], [&(&1 * 2)], [&(&1 * 10)]) -true

+

+ + Examples +

+ +
iex> spotcheck_composition([1, 2], [&(&1 * 2)], [&(&1 * 10)])
+true
@@ -201,11 +209,12 @@

Specs

spotcheck_functor(wrapped_value, fun) - - + + +
@@ -219,13 +228,13 @@

Specs

Being an applicative functor, seq behaves as lift on wrapped values

-

-iex> spotcheck_functor([1,2,3], &(&1 * 10))
-true
+

+ + Examples +

-iex> spotcheck_functor(%Algae.Id{id: 7}, &(&1 * 99)) -true -
+
iex> spotcheck_functor([1,2,3], &(&1 * 10))
+true
@@ -235,11 +244,12 @@

Specs

spotcheck_homomorphism(specemin, val, fun) - - + + +
@@ -254,10 +264,13 @@

Specs

seqing a wrapped function to a wrapped value is the same as wrapping the result of the function on that value.

-

-iex> spotcheck_homomorphism([], 1, &(&1 * 10))
-true
-
+

+ + Examples +

+ +
iex> spotcheck_homomorphism([], 1, &(&1 * 10))
+true
@@ -267,11 +280,12 @@

Specs

spotcheck_identity(value) - - + + +
@@ -285,13 +299,13 @@

Specs

seqing a lifted id to some lifted value v does not change v

-

-iex> spotcheck_identity []
-true
+

+ + Examples +

-iex> spotcheck_identity %Algae.Id{} -true -
+
iex> spotcheck_identity []
+true
@@ -301,11 +315,12 @@

Specs

spotcheck_interchange(bare_val, wrapped_fun) - - + + +
@@ -320,10 +335,13 @@

Specs

The order does not matter when seqing to a wrapped value and a wrapped function.

-

-iex> spotcheck_interchange(1, [&(&1 * 10)])
-true
-
+

+ + Examples +

+ +
iex> spotcheck_interchange(1, [&(&1 * 10)])
+true
@@ -334,23 +352,24 @@

Specs

- + - + diff --git a/doc/Witchcraft.Applicative.Protocol.html b/doc/Witchcraft.Applicative.Protocol.html new file mode 100644 index 0000000..0d13a42 --- /dev/null +++ b/doc/Witchcraft.Applicative.Protocol.html @@ -0,0 +1,260 @@ + + + + + + + + Witchcraft.Applicative.Protocol – Witchcraft v0.5.0 + + + + + + + + + +
+ + + +
+
+
+ + +

+ Witchcraft v0.5.0 + Witchcraft.Applicative.Protocol + + protocol + + + + + + +

+ + + + +
+

+ + + + Summary +

+ +
+

+ Types +

+
+ + +
+
+
+ t() +
+ +
+ +
+ + + +
+

+ Functions +

+
+ + +

Sequentially seq lifted function(s) to lifted data

+
+ +
+
+ + +

Lift a pure value into a type provided by some specemin (usually the zeroth +or empty value of that type, but not nessesarily)

+
+ +
+ +
+ + + + + + +
+ + + +
+

+ + + + Types +

+
+
+
applicative :: any
+ +
+
+
t :: term
+ +
+ +
+
+ + + +
+

+ + + + Functions +

+
+
+ + + + seq(wrapped_value, wrapped_function) + + + + + + +
+ +
+

Specs

+
+ +
seq(applicative, (... -> any)) :: any
+ +
+
+ +
+

Sequentially seq lifted function(s) to lifted data.

+ +
+
+
+
+ + + + wrap(specimen, bare) + + + + + + +
+ +
+

Specs

+
+ +
wrap(any, any) :: any
+ +
+
+ +
+

Lift a pure value into a type provided by some specemin (usually the zeroth +or empty value of that type, but not nessesarily).

+ +
+
+ +
+ + + + + + +
+
+
+
+ + + + diff --git a/doc/Witchcraft.Applicative.Wrap.html b/doc/Witchcraft.Applicative.Wrap.html new file mode 100644 index 0000000..4cdde85 --- /dev/null +++ b/doc/Witchcraft.Applicative.Wrap.html @@ -0,0 +1,183 @@ + + + + + + + + Witchcraft.Applicative.Wrap – Witchcraft v0.5.0 + + + + + + + + + +
+ + + +
+
+
+ + +

+ Witchcraft v0.5.0 + Witchcraft.Applicative.Wrap + + behaviour + + + + + + +

+ + +
+

Define a wrapping function to lift a value into your struct

+ +
+ + + +
+

+ + + + Summary +

+ + + + + + + +
+

+ Callbacks +

+
+
+ wrap(any) +
+ +
+ +
+ + +
+ + + + + + + + + +
+

+ + + + Callbacks +

+
+
+ + + + wrap(any) + + + + + + +
+ +
+

Specs

+
+ +
wrap(any) :: any
+ +
+
+ +
+ +
+
+ +
+ + +
+
+
+
+ + + + diff --git a/doc/Witchcraft.Applicative.html b/doc/Witchcraft.Applicative.html index 8dbe6ac..4593bba 100644 --- a/doc/Witchcraft.Applicative.html +++ b/doc/Witchcraft.Applicative.html @@ -4,30 +4,31 @@ - - Witchcraft.Applicative – Witchcraft v0.4.2 - + + Witchcraft.Applicative – Witchcraft v0.5.0 + + + + - + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Applicative - protocol - - +

-
+

Applicative functors provide a method of seqing a function contained in a data structure to a value of the same type. This allows you to seq and compose functions to values while avoiding repeated manual wrapping and unwrapping of those values.

Properties

-

Identity

+

+ + Identity +

+

seqing a lifted id to some lifted value v does not change v

-

seq(v, wrap(&id(&1))) == v

-

Composition

+
seq(v, wrap(&id(&1))) == v
+

+ + Composition +

+

seq composes normally.

-

seq((wrap &compose(&1,&2)), (seq(u,(seq(v, w))))) == seq(u,(seq(v, w)))

-

Homomorphism

+
seq((wrap &compose(&1,&2)), (seq(u,(seq(v, w))))) == seq(u,(seq(v, w)))
+

+ + Homomorphism +

+

seqing a wrapped function to a wrapped value is the same as wrapping the result of the function on that value.

-

seq(wrap x, wrap f) == wrap f(x))

-

Interchange

+
seq(wrap x, wrap f) == wrap f(x))
+

+ + Interchange +

+

The order does not matter when seqing to a wrapped value and a wrapped function.

-

seq(wrap y, u) == seq(u, wrap &(lift(y, &1))

-

Functor

+
seq(wrap y, u) == seq(u, wrap &(lift(y, &1))
+

+ + Functor +

+

Being an applicative functor, seq behaves as lift on wrapped values

-

lift(x, f) == seq(x, (wrap f))

+
lift(x, f) == seq(x, (wrap f))

Notes

Given that Elixir functons are right-associative, you can write clean looking, but much more ambiguous versions:

-

wrap(y) |> seq(u) == seq(u, wrap(&lift(y, &1)))

-

lift(x, f) == seq(x, wrap f)

+
wrap(y) |> seq(u) == seq(u, wrap(&lift(y, &1)))
+lift(x, f) == seq(x, wrap f)

However, it is strongly recommended to include the parentheses for clarity.

@@ -118,41 +138,108 @@

Summary

-
+ + +

- Types + Functions

+
+ - - - -
-

- Functions -

- + + + +
-

Sequentially seq lifted function(s) to lifted data

+
-

Lift a pure value into a type provided by some specemin (usually the zeroth -or empty value of that type, but not nessesarily)

+ + +
+ +
+ + +

See Witchcraft.Applicative.Wrap.wrap/1

+
+ +
+ + @@ -168,22 +255,6 @@

-
-

- - - - Types -

-
-
-
t :: term
- -
- -
-
-
@@ -193,30 +264,174 @@

Functions

-
+
+
+ + + + func <<~ data + + + + + + +
+ +
+

See Witchcraft.Applicative.Operator.<<~/2.

+ +
+
+
+
+ + + + lift(val_1, val_2, fun) + + + + + + +
+ +
+

See Witchcraft.Applicative.Function.lift/3.

+ +
+
+
+
+ + + + lift(val_1, val_2, val_3, fun) + + + + + + +
+ +
+

See Witchcraft.Applicative.Function.lift/4.

+ +
+
+
+
+ + + + lift(val_1, val_2, val_3, val_4, fun) + + + + + + +
+ +
+

See Witchcraft.Applicative.Function.lift/5.

+ +
+
+
+
+ + + + rewrap(specemin) + + + + + + +
+ +
+

See Witchcraft.Applicative.Function.rewrap/1.

+ +
+
+
- seq(wrapped_value, wrapped_function) - - + seq(applicative, fun) + + +
-
-

Specs

-
- -
seq(any, (... -> any)) :: any
- -
-
+
+

See Witchcraft.Applicative.Protocol.seq/2.

+ +
+
+
+
+ + + + seq_first(first, second) + + + + + + +
+ +
+

See Witchcraft.Applicative.Function.seq_first/2.

+ +
+
+
+
+ + + + seq_second(first, second) + + + + + + +
+ +
+

See Witchcraft.Applicative.Function.seq_second/2.

+ +
+
+
+
+ + + + wrap(bare) + + + + + + +
-

Sequentially seq lifted function(s) to lifted data.

+

See Witchcraft.Applicative.Wrap.wrap/1.

@@ -225,26 +440,36 @@

Specs

- wrap(specimen, bare) - - + wrap(specemin, bare) + + +
-
-

Specs

-
- -
wrap(any, any) :: any
- -
-
+
+

See Witchcraft.Applicative.Protocol.wrap/2.

+ +
+

+
+
+ + + + data ~>> func + + + + + + +
-

Lift a pure value into a type provided by some specemin (usually the zeroth -or empty value of that type, but not nessesarily).

+

See Witchcraft.Applicative.Operator.~>>/2.

@@ -255,23 +480,24 @@

Specs

- +
- + diff --git a/doc/Witchcraft.Functor.Function.html b/doc/Witchcraft.Functor.Function.html index ed91946..e35ccf7 100644 --- a/doc/Witchcraft.Functor.Function.html +++ b/doc/Witchcraft.Functor.Function.html @@ -4,30 +4,31 @@ - - Witchcraft.Functor.Function – Witchcraft v0.4.2 - + + Witchcraft.Functor.Function – Witchcraft v0.5.0 + + + + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Functor.Function - +

-
-

Functions that come directly from lift.

+
+

Functions that come directly from lift

@@ -113,7 +115,7 @@

Replace all of the input’s data nodes with some constant value

@@ -147,25 +149,29 @@

lift() - - + + +

Not strictly a curried version of lift/2. lift/1 partially applies a function, to create a “lifted” version of that function.

-

-iex> x10 = &lift(fn x -> x * 10 end).(&1)
-iex> [1,2,3] |> x10.()
+

+ + Examples +

+ +
iex> x10 = &lift(fn x -> x * 10 end).(&1)
+...> [1,2,3] |> x10.()
 [10,20,30]
 
-iex> x10 = &lift(fn x -> x * 10 end).(&1)
-iex> %Algae.Id{id: 13} |> x10.()
-%Algae.Id{id: 130}
-
+# iex> x10 = &lift(fn x -> x * 10 end).(&1) +# ...> %Algae.Id{id: 13} |> x10.() +# %Algae.Id{id: 130}
@@ -175,11 +181,12 @@

lift(fun) - - + + +

@@ -200,12 +207,13 @@

Specs

- replace(functor_data, const) - - + replace(data, const) + + +
@@ -219,10 +227,13 @@

Specs

Replace all of the input’s data nodes with some constant value

-

-iex> [1,2,3] |> replace(42)
-[42, 42, 42]
-
+

+ + Examples +

+ +
iex> [1,2,3] |> replace(42)
+[42, 42, 42]
@@ -233,23 +244,24 @@

Specs

- +
- + diff --git a/doc/Witchcraft.Functor.Operator.html b/doc/Witchcraft.Functor.Operator.html index d575c08..6a58569 100644 --- a/doc/Witchcraft.Functor.Operator.html +++ b/doc/Witchcraft.Functor.Operator.html @@ -4,30 +4,31 @@ - - Witchcraft.Functor.Operator – Witchcraft v0.4.2 - + + Witchcraft.Functor.Operator – Witchcraft v0.5.0 + + + + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Functor.Operator - +

+
+

Operator aliases for Witchcraft.Operator

+ +
+
@@ -137,11 +144,12 @@

func <~ args - - + + +

@@ -157,10 +165,14 @@

Specs

Alias for lift. As we’ll see with Witchcraft.Applicative, this arrow points in the direction of data flow (just like |>), but we often prefer the function on the left side.

-

-iex> (&(&1 * 10)) <~ [1,2,3]
-[10, 20, 30]
-
+

+ + Examples +

+ +
iex> times10 = fn x -> x * 10 end
+...> times10 <~ [1,2,3]
+[10, 20, 30]
@@ -170,11 +182,12 @@

Specs

args ~> func - - + + +
@@ -188,10 +201,13 @@

Specs

Alias for lift and <~, but with data flowing to the right.

-

-iex> [1,2,3] ~> &(&1 * 10)
-[10, 20, 30]
-
+

+ + Examples +

+ +
iex> [1,2,3] ~> &(&1 * 10)
+[10, 20, 30]
@@ -202,23 +218,24 @@

Specs

- + - + diff --git a/doc/Witchcraft.Functor.Property.html b/doc/Witchcraft.Functor.Property.html index 22c32a8..b21aef9 100644 --- a/doc/Witchcraft.Functor.Property.html +++ b/doc/Witchcraft.Functor.Property.html @@ -4,30 +4,31 @@ - - Witchcraft.Functor.Property – Witchcraft v0.4.2 - + + Witchcraft.Functor.Property – Witchcraft v0.5.0 + + + + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Functor.Property - +

-
+

Check samples of your functor to confirm that your data adheres to the functor properties. All members of your datatype should adhere to these rules. They are placed here as a quick way to spotcheck some of your values.

@@ -161,11 +163,12 @@

spotcheck(context, f, g, typecheck) - - + + +

@@ -179,15 +182,6 @@

Specs

Spotcheck all functor properties

-

-iex> alias Algae.Id, as: Id
-iex> defmodule Typecheck do
-...>   def is_id(%Id{id: _}), do: true
-...>   def is_id(_), do: false
-...> end
-iex> spotcheck(%Id{id: 42}, &(&1 + 1), &(&1 * 2), &Typecheck.is_id/1)
-true
-
@@ -197,11 +191,12 @@

Specs

spotcheck_associates_object(context, func, typecheck) - - + + +
@@ -215,15 +210,6 @@

Specs

Check that lifting a function into some context returns a member of the target type

-

-iex> alias Algae.Id, as: Id
-iex> defmodule Typecheck do
-...>   def is_id(%Id{id: _}), do: true
-...>   def is_id(_), do: false
-...> end
-iex> spotcheck_associates_object(%Id{id: 42}, &Quark.id/1, &Typecheck.is_id/1)
-true
-
@@ -233,11 +219,12 @@

Specs

spotcheck_preserve_compositon(context, f, g) - - + + +
@@ -251,10 +238,6 @@

Specs

Check that lifting a composed function is the same as lifting functions in sequence

-

-iex> spotcheck_preserve_compositon(%Algae.Id{id: 5}, &(&1 + 1), &(&1 * 10))
-true
-
@@ -264,11 +247,12 @@

Specs

spotcheck_preserve_identity(context, func) - - + + +
@@ -291,10 +275,6 @@

Specs

v v B ---- id ----> B -

-iex> spotcheck_preserve_identity(%Algae.Id{id: 7}, &(&1 + 1))
-true
-
@@ -305,23 +285,24 @@

Specs

- + - + diff --git a/doc/Witchcraft.Functor.Protocol.html b/doc/Witchcraft.Functor.Protocol.html new file mode 100644 index 0000000..fb6cb3d --- /dev/null +++ b/doc/Witchcraft.Functor.Protocol.html @@ -0,0 +1,219 @@ + + + + + + + + Witchcraft.Functor.Protocol – Witchcraft v0.5.0 + + + + + + + + + +
+ + + +
+
+
+ + +

+ Witchcraft v0.5.0 + Witchcraft.Functor.Protocol + + protocol + + + + + + +

+ + +
+

The basis of Witchcraft.Functor

+ +
+ + + +
+

+ + + + Summary +

+ +
+

+ Types +

+
+
+ t() +
+ +
+ +
+ + + +
+

+ Functions +

+
+ + +

Apply a function to every element in some collection, tree, +or other structure

+
+ +
+ +
+ + + + + + +
+ + + +
+

+ + + + Types +

+
+
+
t :: term
+ +
+ +
+
+ + + +
+

+ + + + Functions +

+
+
+ + + + lift(data, function) + + + + + + +
+ +
+

Specs

+
+ +
lift(any, (any -> any)) :: any
+ +
+
+ +
+

Apply a function to every element in some collection, tree, +or other structure.

+

The collection will retain its structure (list, tree, and so on).

+ +
+
+ +
+ + + + + + +
+
+
+
+ + + + diff --git a/doc/Witchcraft.Functor.html b/doc/Witchcraft.Functor.html index e795f8b..59ec5cf 100644 --- a/doc/Witchcraft.Functor.html +++ b/doc/Witchcraft.Functor.html @@ -4,30 +4,31 @@ - - Witchcraft.Functor – Witchcraft v0.4.2 - + + Witchcraft.Functor – Witchcraft v0.5.0 + + + + - + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Functor - protocol - - +

-
+

Functors provide a way to apply a function to value(s) a datatype (lists, trees, maybes, etc).

All elements of the data being mapped over need to be consumable by the lifted function. The simplest way to handle this is to have only one type in the data/collection.

-

The term lift is used rather than the more common map. -First, this makes clear that the use is to lift functions into containers. -Second, if you want mapping behaviour on collections, check out +

+ + Terminology +

+ +

The term lift is used rather than the more common map.

+

First, this makes clear that the use is to lift functions into containers.

+

Second, if you want mapping behaviour on collections, check out Enum.map. In fact, the default implimentation is Enum.map, so you can use this with the -build-in datatypes. -Third, the naming becomes more consistent with +build-in datatypes.

+

Third, the naming becomes more consistent with Applicative’s lift2, lift3, and so on.

-

Properties

-

Identity

+

+ + Properties +

+ +

Identity

Mapping the identity function over the object returns the same object ex. lift([1,2,3], id) == [1,2,3]

-

Distributive

+

Distributive

lift(data, (f |> g)) == data |> lift(f) |> lift(g)

-

Associates all objects

+

Associates all objects

Mapping a function onto an object returns a value. ie: does not throw an error, returns a value of the target type (not of the wrong type, or the type none)

-

Notes:

+

+ + Notes: +

+
  • The argument order convention is reversed from most other lanaguges
  • Most (if not all) implimentations of lift should be - expressable in terms of Enum.reduce/3 + expressible in terms of + Enum.reduce/3
  • -
  • Falls back to Enum.map/2 +
  • Falls back to + Enum.map/2
-

Examples

-
iex> [1,2,3] |> lift(&(&1 + 1))
-[2,3,4]
+

+ + Examples +

-iex> defimpl Witchcraft.Functor, for: Algae.Id do -iex> def lift(%Algae.Id{id: inner}, func), do: %Algae.Id{id: func.(inner)} -iex> end -iex> lift(%Algae.Id{id: 1}, &(&1 + 1)) -%Algae.Id{id: 2}
+
iex> [1,2,3] |> lift(&(&1 + 1))
+[2,3,4]
@@ -133,32 +146,63 @@

Summary

-
+ + +

- Types + Functions

+
+
+ lift()
- - - -
-

- Functions -

- + +
-

Apply a function to every element in some collection, tree, or other structure. -The collection will retain its structure (list, tree, and so on)

+ + +
+ + @@ -174,22 +218,6 @@

-
-

- - - - Types -

-
-
-
t :: term
- -
- -
-
-
@@ -199,31 +227,117 @@

Functions

-
+
+
+ + + + func <~ data + + + + + + +
+ +
+

See Witchcraft.Functor.Operator.<~/2.

+ +
+
+
+
+ + + + lift() + + + + + + +
+ +
+

See Witchcraft.Functor.Function.lift/0.

+ +
+
+
+
+ + + + lift(fun) + + + + + + +
+ +
+

See Witchcraft.Functor.Function.lift/1.

+ +
+
+
- lift(data, function) - - + lift(data, fun) + + +
-
-

Specs

-
- -
lift(any, (any -> any)) :: any
- -
-
+
+

See Witchcraft.Functor.Protocol.lift/2.

+ +
+
+
+
+ + + + replace(data, const) + + + + + + +
+ +
+

See Witchcraft.Functor.Function.replace/2.

+ +
+
+
+
+ + + + data ~> func + + + + + + +
-

Apply a function to every element in some collection, tree, or other structure. -The collection will retain its structure (list, tree, and so on).

+

See Witchcraft.Functor.Operator.~>/2.

@@ -234,23 +348,24 @@

Specs

- +

- + diff --git a/doc/Witchcraft.Monad.Function.html b/doc/Witchcraft.Monad.Function.html index 504c569..7863f99 100644 --- a/doc/Witchcraft.Monad.Function.html +++ b/doc/Witchcraft.Monad.Function.html @@ -4,30 +4,31 @@ - - Witchcraft.Monad.Function – Witchcraft v0.4.2 - + + Witchcraft.Monad.Function – Witchcraft v0.5.0 + + + + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Monad.Function - +

-
- +
+

Function helpers, derivatives and operators for Witchcraft.Monad

+
@@ -96,10 +99,12 @@

-
+

Operate on data wrapped inside of a monadic struct. Conceptually (though not actually) +it unwraps the data, applies the function, and wraps the data up again

+
@@ -128,12 +133,13 @@

- bind(data, fun) - - + bind(data, binder) + + +

@@ -146,7 +152,34 @@

Specs

- +

Operate on data wrapped inside of a monadic struct. Conceptually (though not actually) +it unwraps the data, applies the function, and wraps the data up again.

+

Note that when several binds are chained, the later calls will have a strict data +dependency on the earlier computations. This allows for parameter bindings from +anonymous functions to be propagated through a series of logical steps (hence “bind”).

+
iex> bind([1], fn x -> [x+1] end)
+[2]
+
+iex> bind(
+...>   bind(
+...>     bind(
+...>       [1],
+...>       fn x -> [1 + x] end
+...>     ),
+...>     fn y -> [10 * y] end
+...>   ),
+...>   fn z -> [100 - z] end
+...> )
+[80]
+

More classic style allowing for variable sharing +(easier with the >>> operator in Witchcraft.Monad.Operator

+
iex> bind([1,2,3], fn x ->
+...>   bind([x + 1], fn y ->
+...>     [x * y]
+...>   end)
+...> end)
+[2, 6, 12]
+
@@ -156,23 +189,24 @@

Specs

- +
- + diff --git a/doc/Witchcraft.Monad.Operator.html b/doc/Witchcraft.Monad.Operator.html index 311cece..4174c31 100644 --- a/doc/Witchcraft.Monad.Operator.html +++ b/doc/Witchcraft.Monad.Operator.html @@ -4,30 +4,31 @@ - - Witchcraft.Monad.Operator – Witchcraft v0.4.2 - + + Witchcraft.Monad.Operator – Witchcraft v0.5.0 + + + + +
-
+
+ -

Alias for bind

+

Operator alias for bind, with arguments reversed

+
+
+ + +
+
-

Alias for bind

+

Operator alias for bind

@@ -135,11 +150,12 @@

fun <<< wrapped - - + + +

@@ -152,27 +168,57 @@

Specs

-

Alias for bind

-

-iex> &(wrap(&1 * 1)) <<< [1,2,3]
-[10, 20, 30]
-
+    

Operator alias for bind, with arguments reversed

+

+ + Examples +

-
+
iex> use Witchcraft.Applicative
+...> fn x -> [x * 10] end <<< [1,2,3]
+[10, 20, 30]
+
+
+ + + + bind_a <~> bind_b + + + + + + +
+ +
+

Specs

+
+ +
(... -> any) <~> (... -> any) :: (... -> any)
+ +
+
+ +
+ +
+
wrapped >>> fun - - + + +
@@ -185,13 +231,22 @@

Specs

-

Alias for bind

-

-iex> [1,2,3] >>> &(wrap(&1 * 1))
-[10, 20, 30]
+    

Operator alias for bind

+

+ + Examples +

+
iex> use Witchcraft.Applicative
+...> [1,2,3] >>> fn x -> [x * 10] end
+[10, 20, 30]
 
-
+iex> [1,2,3] >>> fn x -> +...> [x+1] >>> fn y -> +...> [y*x, y*10, x-1] +...> end +...> end +[2,20,0,6,30,1,12,40,2]
@@ -202,23 +257,24 @@

Specs

- +
- + diff --git a/doc/Witchcraft.Monad.Property.html b/doc/Witchcraft.Monad.Property.html new file mode 100644 index 0000000..2ca70de --- /dev/null +++ b/doc/Witchcraft.Monad.Property.html @@ -0,0 +1,237 @@ + + + + + + + + Witchcraft.Monad.Property – Witchcraft v0.5.0 + + + + + + + + + +
+ + + +
+
+
+ + +

+ Witchcraft v0.5.0 + Witchcraft.Monad.Property + + + + + + +

+ + +
+

Properties to help ensure that your defimpl is sane

+ +
+ + + +
+

+ + + + Summary +

+ + + + + + + + + + + + +
+ + + + + +
+

+ + + + Functions +

+
+
+ + + + spotcheck_right_identity(value, fun) + + + + + + +
+ +
+ +
+
+ +
+ + + +
+

+ + + + Macros +

+
+
+ + + + spotcheck_associativity(value, f, g) + + + + + + +
+ +
+ +
+
+
+
+ + + + spotcheck_left_identity(value, fun) + + + + + + +
+ +
+ +
+
+ +
+ + + + +
+
+
+
+ + + + diff --git a/doc/Witchcraft.Monad.Protocol.html b/doc/Witchcraft.Monad.Protocol.html new file mode 100644 index 0000000..d133387 --- /dev/null +++ b/doc/Witchcraft.Monad.Protocol.html @@ -0,0 +1,227 @@ + + + + + + + + Witchcraft.Monad.Protocol – Witchcraft v0.5.0 + + + + + + + + + +
+ + + +
+
+
+ + +

+ Witchcraft v0.5.0 + Witchcraft.Monad.Protocol + + protocol + + + + + + +

+ + +
+

The bases for Witchcraft.Monad

+ +
+ + + +
+

+ + + + Summary +

+ +
+

+ Types +

+
+
+ t() +
+ +
+ +
+ + + +
+

+ Functions +

+
+ + +

join takes a recursively nested data structure, and joins the two outermost +levels together to result in one level. This may be seen as a “flattening” +operation for most datatypes

+
+ +
+ +
+ + + + + + +
+ + + +
+

+ + + + Types +

+
+
+
t :: term
+ +
+ +
+
+ + + +
+

+ + + + Functions +

+
+
+ + + + join(deep) + + + + + + +
+ +
+

Specs

+
+ +
join(any) :: any
+ +
+
+ +
+

join takes a recursively nested data structure, and joins the two outermost +levels together to result in one level. This may be seen as a “flattening” +operation for most datatypes.

+

+ + Examples +

+ +
iex>  join [[[1,2,3]]]
+[[1,2,3]]
+ +
+
+ +
+ + + + + + +
+
+
+
+ + + + diff --git a/doc/Witchcraft.Monad.html b/doc/Witchcraft.Monad.html index f8314f4..2ddc9ad 100644 --- a/doc/Witchcraft.Monad.html +++ b/doc/Witchcraft.Monad.html @@ -4,30 +4,31 @@ - - Witchcraft.Monad – Witchcraft v0.4.2 - + + Witchcraft.Monad – Witchcraft v0.5.0 + + + + - + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Monad - protocol - - +

-
-

Because we are following Functor/Applicative/Monad superclassing, return is pure, -so no need to define return. bind can be defined in terms of join and lift.

+
+

Because we are following the Functor -> Applicative -> Monad hierarchy, +return is already defined as pure. bind can be defined in terms of join +and lift, so we only need to define join for monads.

@@ -92,31 +93,55 @@

Summary

-
+ + +

- Types + Functions

+
+ - - - -
-

- Functions -

- + +
+ + +

See Witchcraft.Monad.Function.compose/2

+
+ +
+ @@ -131,22 +156,6 @@

-
-

- - - - Types -

-
-
-
t :: term
- -
- -
-
-
@@ -156,30 +165,99 @@

Functions

-
+
-
-

Specs

-
- -
join(any) :: any
- -
-
+
+

See Witchcraft.Monad.Operator.<<</2.

+ +
+
+
+
+ + + + wrapped >>> fun + + + + + + +
+

See Witchcraft.Monad.Operator.>>>/2.

+ +
+
+
+
+ + + + bind(data, binder) + + + + + +
+ +
+

See Witchcraft.Monad.Function.bind/2.

+ +
+
+
+
+ + + + compose(fun_one, fun_two) + + + + + + +
+ +
+

See Witchcraft.Monad.Function.compose/2.

+ +
+
+
+
+ + + + join(deep) + + + + + + +
+ +
+

See Witchcraft.Monad.Protocol.join/1.

+
@@ -189,23 +267,24 @@

Specs

- +

- + diff --git a/doc/Witchcraft.Monoid.Identity.html b/doc/Witchcraft.Monoid.Identity.html new file mode 100644 index 0000000..bba577b --- /dev/null +++ b/doc/Witchcraft.Monoid.Identity.html @@ -0,0 +1,183 @@ + + + + + + + + Witchcraft.Monoid.Identity – Witchcraft v0.5.0 + + + + + + + + + +
+ + + +
+
+
+ + +

+ Witchcraft v0.5.0 + Witchcraft.Monoid.Identity + + behaviour + + + + + + +

+ + +
+

Get the identity without providing a sample value

+ +
+ + + +
+

+ + + + Summary +

+ + + + + + + +
+

+ Callbacks +

+
+ + +
+ +
+ + +
+ + + + + + + + + +
+

+ + + + Callbacks +

+
+
+ + + + identity() + + + + + + +
+ +
+

Specs

+
+ +
identity :: any
+ +
+
+ +
+ +
+
+ +
+ + +
+
+
+
+ + + + diff --git a/doc/Witchcraft.Monoid.Operator.html b/doc/Witchcraft.Monoid.Operator.html index ff23dc0..697a97e 100644 --- a/doc/Witchcraft.Monoid.Operator.html +++ b/doc/Witchcraft.Monoid.Operator.html @@ -4,30 +4,31 @@ - - Witchcraft.Monoid.Operator – Witchcraft v0.4.2 - + + Witchcraft.Monoid.Operator – Witchcraft v0.5.0 + + + + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Monoid.Operator - +

+
+

Operator aliases for Witchcraft.Monoid

+ +
+
@@ -92,7 +99,7 @@

Infix variant of Monoid.append

@@ -120,50 +127,51 @@

Functions

-
+
- + - a <|> b - - + a <> b + + +

Specs

-
any <|> any :: any
+
any <> any :: any

Infix variant of Monoid.append

-

Example

-

-iex> import Witchcraft.Monoid
-...> defimpl Witchcraft.Monoid, for: Integer do
-...>   def identity(_), do: 0
-...>   def append(a, b), do: a + b
-...> end
-iex> 1 |> append(4) |> append(2) |> append(10)
+

+ + Examples +

+ +
iex> use Witchcraft.Monoid
+...> 1 |> append(4) |> append(2) |> append(10)
 17
 
-iex> 1 <|> 4 <|> 2 <|> 10
+iex> import Kernel, except: [<>: 2]
+...> 1 <> 4 <> 2 <> 10
 17
 
-iex> import Witchcraft.Monoid
-iex> 1 |> append(4) |> append(2) |> append(10)
+iex> use Witchcraft.Monoid
+...> 1 |> append(4) |> append(2) |> append(10)
 17
 
-iex> [42, 43] <|> [44] <|> [45, 46] <|> [47]
-[42, 43, 44, 45, 46, 47]
-
+iex> import Kernel, except: [<>: 2] +...> [42, 43] <> [44] <> [45, 46] <> [47] +[42, 43, 44, 45, 46, 47]
@@ -174,23 +182,24 @@

Example

- +
- + diff --git a/doc/Witchcraft.Monoid.Property.html b/doc/Witchcraft.Monoid.Property.html index bccaab5..116f2f5 100644 --- a/doc/Witchcraft.Monoid.Property.html +++ b/doc/Witchcraft.Monoid.Property.html @@ -4,30 +4,31 @@ - - Witchcraft.Monoid.Property – Witchcraft v0.4.2 - + + Witchcraft.Monoid.Property – Witchcraft v0.5.0 + + + + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Monoid.Property - +

-
+

Check samples of your monoid to confirm that your data adheres to the monoidal properties. All members of your datatype should adhere to these rules. They are placed here as a quick way to spotcheck some of your values.

@@ -152,11 +154,12 @@

spotcheck(a, b, c) - - + + +

@@ -170,14 +173,8 @@

Specs

Spotcheck all monoid properties

-

-iex> spotcheck(1,2,3)
-true
-
-# Float under division
-iex> spotcheck(%Witchcraft.Sad{sad: -9.1}, %Witchcraft.Sad{sad: 42.0}, %Witchcraft.Sad{sad: 88.8})
-false
-
+
iex> spotcheck(1,2,3)
+true
@@ -187,11 +184,12 @@

Specs

spotcheck_associativity(member1, member2, member3) - - + + +
@@ -206,14 +204,8 @@

Specs

Check that Monoid.append is associative (ie: brackets don’t matter)

-

-iex> spotcheck_associativity("a", "b", "c")
-true
-
-# Float under division
-iex> spotcheck_associativity(%Witchcraft.Sad{sad: -9.1}, %Witchcraft.Sad{sad: 42.0}, %Witchcraft.Sad{sad: 88.8})
-false
-
+
iex> spotcheck_associativity("a", "b", "c")
+true
@@ -223,11 +215,12 @@

Specs

spotcheck_identity(member) - - + + +
@@ -241,14 +234,8 @@

Specs

Check that some member of your monoid combines with the identity to return itself

-

-iex> spotcheck_identity("well formed")
-true
-
-# Float under division
-iex> spotcheck_identity(%Witchcraft.Sad{})
-false
-
+
iex> spotcheck_identity("well formed")
+true
@@ -259,23 +246,24 @@

Specs

- +
- + diff --git a/doc/Witchcraft.Monoid.Protocol.html b/doc/Witchcraft.Monoid.Protocol.html new file mode 100644 index 0000000..0011d50 --- /dev/null +++ b/doc/Witchcraft.Monoid.Protocol.html @@ -0,0 +1,256 @@ + + + + + + + + Witchcraft.Monoid.Protocol – Witchcraft v0.5.0 + + + + + + + + + +
+ + + +
+
+
+ + +

+ Witchcraft v0.5.0 + Witchcraft.Monoid.Protocol + + protocol + + + + + + +

+ + +
+

TODO WRITE STUFF

+

Notes

+

You can of course abuse this protocol to define a fake ‘monoid’ that behaves differently. +For the protocol to operate as intended, you need to respect the above properties.

+ +
+ + + +
+

+ + + + Summary +

+ +
+

+ Types +

+
+
+ t() +
+ +
+ +
+ + + +
+

+ Functions +

+
+ + +

Combine two members of the monoid, and return another member

+
+ +
+
+ + +

Get the identity (‘zero’) element of the monoid by passing in any element of the set

+
+ +
+ +
+ + + + + + +
+ + + +
+

+ + + + Types +

+
+
+
t :: term
+ +
+ +
+
+ + + +
+

+ + + + Functions +

+
+
+ + + + append(a, b) + + + + + + +
+ +
+

Specs

+
+ +
append(any, any) :: any
+ +
+
+ +
+

Combine two members of the monoid, and return another member

+ +
+
+
+
+ + + + identity(a) + + + + + + +
+ +
+

Specs

+
+ +
identity(any) :: any
+ +
+
+ +
+

Get the identity (‘zero’) element of the monoid by passing in any element of the set

+ +
+
+ +
+ + + + + + +
+
+
+
+ + + + diff --git a/doc/Witchcraft.Monoid.html b/doc/Witchcraft.Monoid.html index e23d235..2c291e4 100644 --- a/doc/Witchcraft.Monoid.html +++ b/doc/Witchcraft.Monoid.html @@ -4,30 +4,31 @@ - - Witchcraft.Monoid – Witchcraft v0.4.2 - + + Witchcraft.Monoid – Witchcraft v0.5.0 + + + + - + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Monoid - protocol - - +

-
+

Monoids are a set of elements, and a binary combining operation (op) that returns another member of the set.

Properties

-

Associativity

+

+ + Associativity +

+
  1. Given a binary joining operation ,
  2. @@ -89,28 +93,31 @@

    Associativity

  3. then: a • (b • c) == (a • b) • c
-

Identity element

+

+ + Identity element +

+
  • Unique element (id, sometimes called the ‘zero’ of the set)
  • -
  • Behaves as an identity with op +
  • Behaves as an identity with op

    +

    identity = 0 +op = &(&1 + &2) # Integer addition +append(34, identity) == 34

    +

    identity = 1 +append = &(&1 * &2) # Integer multiplication +append(42, identity) == 42

-

-identity = 0
-op = &(&1 + &2) # Integer addition
-append(34, identity) == 34
+

+ + Counter-Example +

-identity = 1 -append = &(&1 * &2) # Integer multiplication -append(42, identity) == 42 -
-

Counter-Example

Integer division is not a monoid. -Because you cannot divide by zero, the property does not hold for all values in the set.

-

Notes

-

You can of course abuse this protocol to define a fake ‘monoid’ that behaves differently. -For the protocol to operate as intended, you need to respect the above properties.

+Because you cannot divide by zero, the property does not hold +for all values in the set.

@@ -124,19 +131,6 @@

Summary

-
-

- Types -

-
-
- t() -
- -
- -
-
@@ -144,11 +138,20 @@

Functions

+
-

Combine two members of the monoid, and return another member

+
@@ -157,7 +160,7 @@

identity(a)

-

Get the identity (‘zero’) element of the monoid by passing in any element of the set

+
@@ -173,22 +176,6 @@

-
-

- - - - Types -

-
-
-
t :: term
- -
- -
-
-
@@ -198,30 +185,41 @@

Functions

-
+
+
+ + + + a <> b + + + + + + +
+ +
+

See Witchcraft.Monoid.Operator.<>/2.

+ +
+
+
append(a, b) - - + + +
-
-

Specs

-
- -
append(any, any) :: any
- -
-
-
-

Combine two members of the monoid, and return another member

+

See Witchcraft.Monoid.Protocol.append/2.

@@ -231,24 +229,16 @@

Specs

identity(a) - - + + +
-
-

Specs

-
- -
identity(any) :: any
- -
-
-
-

Get the identity (‘zero’) element of the monoid by passing in any element of the set

+

See Witchcraft.Monoid.Protocol.identity/1.

@@ -259,23 +249,24 @@

Specs

- +
- + diff --git a/doc/Witchcraft.Sad.html b/doc/Witchcraft.Sad.html index cf1b4c1..9976761 100644 --- a/doc/Witchcraft.Sad.html +++ b/doc/Witchcraft.Sad.html @@ -4,30 +4,31 @@ - - Witchcraft.Sad – Witchcraft v0.4.2 - + + Witchcraft.Sad – Witchcraft v0.5.0 + + + + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft.Sad - +

-
+

Breaking counterexample for testing

@@ -89,23 +91,24 @@

- +

- + diff --git a/doc/Witchcraft.html b/doc/Witchcraft.html index df36147..873a76b 100644 --- a/doc/Witchcraft.html +++ b/doc/Witchcraft.html @@ -4,30 +4,31 @@ - - Witchcraft – Witchcraft v0.4.2 - + + Witchcraft – Witchcraft v0.5.0 + + + + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 Witchcraft - +

-
-

For convenience, the most common functions and operators are exported at the top-level

- -
- - - -
-

- - - - Summary -

- - - - - - - - - +
+

Convenient top-level use

@@ -280,379 +85,30 @@

-
-

- - - - Functions -

-
-
- - - - fun <<< wrapped - - - - - -
- -
-

See Witchcraft.Monad.Operator.<<</2.

- -
-
-
-
- - - - fun <<~ value - - - - - -
- -
-

See Witchcraft.Applicative.Operator.<<~/2.

- -
-
-
-
- - - - a <|> b - - - - - -
- -
-

See Witchcraft.Monoid.Operator.<|>/2.

- -
-
-
-
- - - - func <~ data - - - - - -
- -
-

See Witchcraft.Functor.Operator.<~/2.

- -
-
-
-
- - - - wrapped >>> fun - - - - - -
- -
-

See Witchcraft.Monad.Operator.>>>/2.

- -
-
-
-
- - - - append(a, b) - - - - - -
- -
-

See Witchcraft.Monoid.append/2.

- -
-
-
-
- - - - apply(wrapped_value, wrapped_function) - - - - - -
- -
-

See Witchcraft.Applicative.apply/2.

- -
-
-
-
- - - - bind(wrapped, fun) - - - - - -
- -
-

See Witchcraft.Monad.Function.bind/2.

- -
-
-
-
- - - - identity(specemin) - - - - - -
- -
-

See Witchcraft.Monoid.identity/1.

- -
-
-
-
- - - - join(deep) - - - - - -
- -
-

See Witchcraft.Monad.join/1.

- -
-
-
-
- - - - lift() - - - - - -
- -
-

See Witchcraft.Functor.Function.lift/0.

- -
-
-
-
- - - - lift(function) - - - - - -
- -
-

See Witchcraft.Functor.Function.lift/1.

- -
-
-
-
- - - - lift(data, function) - - - - - -
- -
-

See Witchcraft.Functor.lift/2.

- -
-
-
-
- - - - replace(functor_data, const) - - - - - -
- -
-

See Witchcraft.Functor.Function.replace/2.

- -
-
-
-
- - - - seq_first(list) - - - - - -
- -
-

See Witchcraft.Applicative.Function.seq_first/1.

- -
-
-
-
- - - - seq_second(list) - - - - - -
- -
-

See Witchcraft.Applicative.Function.seq_second/1.

- -
-
-
-
- - - - wrap(specemin, bare) - - - - - -
- -
-

See Wicthcraft.Applicative.wrap/2.

- -
-
-
-
- - - - data ~> func - - - - - -
- -
-

See Witchcraft.Functor.Operator.~>/2.

- -
-
-
-
- - - - value ~>> fun - - - - - -
- -
-

See Witchcraft.Applicative.Operator.~>>/2.

-
-
- -
- +

- + diff --git a/doc/api-reference.html b/doc/api-reference.html index 53b1f3a..6ce07e8 100644 --- a/doc/api-reference.html +++ b/doc/api-reference.html @@ -4,30 +4,31 @@ - - API Reference – Witchcraft v0.4.2 - + + API Reference – Witchcraft v0.5.0 + + + + +
-
+
+

- Witchcraft v0.4.2 + Witchcraft v0.5.0 API Reference

@@ -83,14 +85,25 @@

Modules

-

For convenience, the most common functions and operators are exported at the top-level

+

Convenient top-level use

+
+ +
+
+ + +

Applicative functors provide a method of seqing a function contained in a +data structure to a value of the same type. This allows you to seq and compose +functions to values while avoiding repeated manual wrapping and unwrapping +of those values

-

Function helpers, derivatives and operators for Witchcraft.Applicative

+

Function helpers, derivatives and operators for +Witchcraft.Applicative.Protocol

@@ -108,6 +121,21 @@

Modules

plus implement Witchcraft.Functor

+
+
+ + +

Define a wrapping function to lift a value into your struct

+
+ +
+
+ + +

Functors provide a way to apply a function to value(s) a datatype +(lists, trees, maybes, etc)

+
+
@@ -119,6 +147,9 @@

Modules

+

Operator aliases for Witchcraft.Operator

+
+
@@ -128,20 +159,58 @@

Modules

They are placed here as a quick way to spotcheck some of your values

+
+
+ + +

Because we are following the Functor -> Applicative -> Monad hierarchy, +return is already defined as pure. bind can be defined in terms of join +and lift, so we only need to define join for monads

+
+
-
+

Function helpers, derivatives and operators for Witchcraft.Monad

+
+

Operator aliases for Witchcraft.Monad

+
+ +
+
+ + +

Properties to help ensure that your defimpl is sane

+
+ +
+
+ + +

Monoids are a set of elements, and a binary combining operation (op) that +returns another member of the set

+
+ +
+
+ + +

Get the identity without providing a sample value

+
+
+

Operator aliases for Witchcraft.Monoid

+
+
@@ -171,36 +240,27 @@

Modules

Protocols

- - -

Applicative functors provide a method of seqing a function contained in a -data structure to a value of the same type. This allows you to seq and compose -functions to values while avoiding repeated manual wrapping and unwrapping -of those values

-
+
- + -

Functors provide a way to apply a function to value(s) a datatype -(lists, trees, maybes, etc)

+

The basis of Witchcraft.Functor

- + -

Because we are following Functor/Applicative/Monad superclassing, return is pure, -so no need to define return. bind can be defined in terms of join and lift

+

The bases for Witchcraft.Monad

- + -

Monoids are a set of elements, and a binary combining operation (op) that -returns another member of the set

+

TODO WRITE STUFF

@@ -208,23 +268,24 @@

Protocols

- +
- + diff --git a/doc/dist/app-6d2e071366.js b/doc/dist/app-6d2e071366.js deleted file mode 100644 index a5cf0a4..0000000 --- a/doc/dist/app-6d2e071366.js +++ /dev/null @@ -1,6 +0,0 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}(function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(typeof e[t]){case"function":break;case"object":e[t]=function(t){var n=t.slice(1),r=e[t[0]];return function(e,t,i){r.apply(this,[e,t,i].concat(n))}}(e[t]);break;default:e[t]=e[e[t]]}return e}([function(e,t,n){"use strict";var r=n(1)["default"],i=n(2),a=r(i),o=n(3),s=r(o),l=n(4),c=n(95),u=n(96);window.$=a["default"],a["default"](function(){s["default"].configure({tabReplace:" ",languages:[]}),u.initialize(),c.initialize(),l.initialize(),s["default"].initHighlighting()})},function(e,t){"use strict";t["default"]=function(e){return e&&e.__esModule?e:{"default":e}},t.__esModule=!0},function(e,t,n){var r,i;!function(t,n){"object"==typeof e&&"object"==typeof e.exports?e.exports=t.document?n(t,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return n(e)}:n(t)}("undefined"!=typeof window?window:this,function(n,a){function o(e){var t="length"in e&&e.length,n=re.type(e);return"function"===n||re.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function s(e,t,n){if(re.isFunction(t))return re.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return re.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(fe.test(t))return re.filter(t,e,n);t=re.filter(t,e)}return re.grep(e,function(e){return V.call(t,e)>=0!==n})}function l(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function c(e){var t=ye[e]={};return re.each(e.match(ve)||[],function(e,n){t[n]=!0}),t}function u(){te.removeEventListener("DOMContentLoaded",u,!1),n.removeEventListener("load",u,!1),re.ready()}function f(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=re.expando+f.uid++}function d(e,t,n){var r;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(ke,"-$1").toLowerCase(),n=e.getAttribute(r),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:Ee.test(n)?re.parseJSON(n):n}catch(i){}we.set(e,t,n)}else n=void 0;return n}function p(){return!0}function h(){return!1}function g(){try{return te.activeElement}catch(e){}}function m(e,t){return re.nodeName(e,"table")&&re.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function v(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function y(e){var t=Be.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function b(e,t){for(var n=0,r=e.length;r>n;n++)_e.set(e[n],"globalEval",!t||_e.get(t[n],"globalEval"))}function x(e,t){var n,r,i,a,o,s,l,c;if(1===t.nodeType){if(_e.hasData(e)&&(a=_e.access(e),o=_e.set(t,a),c=a.events)){delete o.handle,o.events={};for(i in c)for(n=0,r=c[i].length;r>n;n++)re.event.add(t,i,c[i][n])}we.hasData(e)&&(s=we.access(e),l=re.extend({},s),we.set(t,l))}}function _(e,t){var n=e.getElementsByTagName?e.getElementsByTagName(t||"*"):e.querySelectorAll?e.querySelectorAll(t||"*"):[];return void 0===t||t&&re.nodeName(e,t)?re.merge([e],n):n}function w(e,t){var n=t.nodeName.toLowerCase();"input"===n&&Se.test(e.type)?t.checked=e.checked:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}function E(e,t){var r,i=re(t.createElement(e)).appendTo(t.body),a=n.getDefaultComputedStyle&&(r=n.getDefaultComputedStyle(i[0]))?r.display:re.css(i[0],"display");return i.detach(),a}function k(e){var t=te,n=We[e];return n||(n=E(e,t),"none"!==n&&n||(ze=(ze||re("