Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spelling #2381

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions core/src/main/scala/scalaz/Apply.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ trait Apply[F[_]] extends Functor[F] { self =>
f(seed) map { case (fa, s) => go(map(fa)(R.unit), s) }
}

/**The composition of Applys `F` and `G`, `[x]F[G[x]]`, is a Apply */
/**The composition of `Apply`s `F` and `G`, `[x]F[G[x]]`, is a Apply */
def compose[G[_]](implicit G0: Apply[G]): Apply[λ[α => F[G[α]]]] =
new CompositionApply[F, G] {
implicit def F = self
implicit def G = G0
}

/**The product of Applys `F` and `G`, `[x](F[x], G[x]])`, is a Apply */
/**The product of `Apply`s `F` and `G`, `[x](F[x], G[x]])`, is a Apply */
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a reasonable match to the use of Apply on line 60

def product[G[_]](implicit G0: Apply[G]): Apply[λ[α => (F[α], G[α])]] =
new ProductApply[F, G] {
implicit def F = self
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/scalaz/Day.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package scalaz
*
* Day convolution is a special form of Functor multiplication.
* In monoidal category of endofunctors Applicative is a monoid object when Day covolution is used as tensor.
* If we use Functor composition as tensor then then monoid form a Monad instead of Applicative.
* If we use Functor composition as tensor then the monoid form a Monad instead of Applicative.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not at all sure about this.

*
* Can be seen as generalization of method apply2 from Apply:
* {{{
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/scalaz/Dequeue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package scalaz
* A queue that allows items to be put onto either the front (cons)
* or the back (snoc) of the queue in constant time, and constant
* time access to the element at the very front or the very back of
* the queue. Dequeueing an element from either end is constant time
* the queue. Dequeuing an element from either end is constant time
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to drop this or anything else.

* when amortized over a number of dequeues.
*
* This queue maintains an invariant that whenever there are at least
Expand Down
7 changes: 5 additions & 2 deletions core/src/main/scala/scalaz/Heap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ object Heap extends HeapInstances {
}

def skewMeld[A](f: (A, A) => Boolean, ts: Forest[A], tsp: Forest[A]) =
unionUniq(f)(uniqify(f)(ts), uniqify(f)(tsp))
unionUniq(f)(uniquify(f)(ts), uniquify(f)(tsp))

def ins[A](f: (A, A) => Boolean, t: Tree[Ranked[A]]): Forest[A] => Forest[A] = {
case s if s.isEmpty => EphemeralStream(t)
Expand All @@ -409,11 +409,14 @@ object Heap extends HeapInstances {
ins(f, link(f)(t, tp))(ts)
}

def uniqify[A](f: (A, A) => Boolean): Forest[A] => Forest[A] = {
def uniquify[A](f: (A, A) => Boolean): Forest[A] => Forest[A] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a public API. We should keep the original method for backward compatibility.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a deprecated method with the original name that calls this method: https://github.com/scalaz/scalaz/compare/3b0bbbf7de95f0b02288c57aa839462f2deca9e3..561f47ff91cdcc603cf9ac048b831e88bf504730

Does that do what you're looking for?

Are there other methods that need this treatment?

case s if s.isEmpty => emptyEphemeralStream
case (t ##:: ts) => ins(f, t)(ts)
}

@deprecated("Use uniquify", "")
def uniqify[A](f: (A, A) => Boolean): Forest[A] => Forest[A] = uniquify(f)

def unionUniq[A](f: (A, A) => Boolean): (Forest[A], Forest[A]) => Forest[A] = {
case (s, ts) if s.isEmpty => ts
case (ts, s) if s.isEmpty => ts
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/scalaz/ISet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ sealed abstract class ISet[A] {
* When `Order` instances are viewed as "mere" equivalences (as opposed
* to equalities), we can loosely say that `ISet` is an (endo-)functor
* in the category _Equiv_ of sets with an equivalence relation (where
* the morphishms are equivalence-preserving functions, i.e. exactly the
* the morphisms are equivalence-preserving functions, i.e. exactly the
* functions satisfying the above requirement). By contrast, [[Functor]]
* instances are functors in the _Scala_ category, whose morphisms are
* arbitrary functions, including the ones that don't preserve equivalence.
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/scala/scalaz/Nondeterminism.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ trait Nondeterminism[F[_]] extends Monad[F] { self =>
}

/**
* Apply a function to the results of `a` and `b`, nondeterminstically
* Apply a function to the results of `a` and `b`, nondeterministically
* ordering their effects.
*/
def mapBoth[A,B,C](a: F[A], b: F[B])(f: (A,B) => C): F[C] =
Expand All @@ -88,31 +88,31 @@ trait Nondeterminism[F[_]] extends Monad[F] { self =>


/**
* Apply a function to 2 results, nondeterminstically ordering their effects, alias of mapBoth
* Apply a function to 2 results, nondeterministically ordering their effects, alias of mapBoth
*/
def nmap2[A,B,C](a: F[A], b: F[B])(f: (A,B) => C): F[C] =
mapBoth(a,b)(f)

/**
* Apply a function to 3 results, nondeterminstically ordering their effects
* Apply a function to 3 results, nondeterministically ordering their effects
*/
def nmap3[A,B,C,R](a: F[A], b: F[B], c: F[C])(f: (A,B,C) => R): F[R] =
nmap2(nmap2(a, b)((_,_)), c)((ab,c) => f(ab._1, ab._2, c))

/**
* Apply a function to 4 results, nondeterminstically ordering their effects
* Apply a function to 4 results, nondeterministically ordering their effects
*/
def nmap4[A,B,C,D,R](a: F[A], b: F[B], c: F[C], d: F[D])(f: (A,B,C,D) => R): F[R] =
nmap2(nmap2(a, b)((_,_)), nmap2(c,d)((_,_)))((ab,cd) => f(ab._1, ab._2, cd._1, cd._2))

/**
* Apply a function to 5 results, nondeterminstically ordering their effects
* Apply a function to 5 results, nondeterministically ordering their effects
*/
def nmap5[A,B,C,D,E,R](a: F[A], b: F[B], c: F[C], d: F[D], e: F[E])(f: (A,B,C,D,E) => R): F[R] =
nmap2(nmap2(a, b)((_,_)), nmap3(c,d,e)((_,_,_)))((ab,cde) => f(ab._1, ab._2, cde._1, cde._2, cde._3))

/**
* Apply a function to 6 results, nondeterminstically ordering their effects
* Apply a function to 6 results, nondeterministically ordering their effects
*/
def nmap6[A,B,C,D,E,FF,R](a: F[A], b: F[B], c: F[C], d: F[D], e: F[E], ff:F[FF])(f: (A,B,C,D,E,FF) => R): F[R] =
nmap2(nmap3(a, b, c)((_,_,_)), nmap3(d,e,ff)((_,_,_)))((abc,deff) => f(abc._1, abc._2, abc._3, deff._1, deff._2, deff._3))
Expand All @@ -128,7 +128,7 @@ trait Nondeterminism[F[_]] extends Monad[F] { self =>
* Nondeterministically gather results from the given sequence of actions
* to a list. Same as calling `reduceUnordered` with the `List` `Monoid`.
*
* To preserve the order of the output list while allowing nondetermininstic
* To preserve the order of the output list while allowing nondeterministic
* ordering of effects, use `gather`.
*/
def gatherUnordered[A](fs: IList[F[A]]): F[IList[A]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ object ContravariantCoyonedaUsage {
s.foldMap{case (st, i) => recItem[BinOrd](i, sortTypeBinOrd(st))}

// The drawback here is that I can’t just build a separate stack
// willynilly for `Binfmt'. I have to prove at each step that *the
// willy nilly for `Binfmt'. I have to prove at each step that *the
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Google Sheets made this (and most of the other corrections). I probably wouldn't have actively made it, but it's right.

// same* `I' is used for the `Binfmt' and the `Order' for this to be
// useful. Once again, an idea of a fold step that can be fused
// with the `Order' construction safely can be abstracted out here.
Expand Down
4 changes: 2 additions & 2 deletions example/src/main/scala/scalaz/example/FreeMonadsUsage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object FreeMonadsUsage {
type Ast[a] = Coproduct[StateAst, Console.Ast, a]

// scala implicit search fail... needs a helping hand without SI-2712
implicit val injecter: StateAst :<: Ast = Inject.leftInjectInstance
implicit val injector: StateAst :<: Ast = Inject.leftInjectInstance

type F[a] = Free[Ast, a]
// these generators are not implicit by default for compile perf
Expand All @@ -66,7 +66,7 @@ object FreeMonadsUsage {
type Ast[a] = Coproduct[TellAst, Console.Ast, a]

// omg SI-2712...
implicit val injecter: TellAst :<: Ast = Inject.leftInjectInstance
implicit val injector: TellAst :<: Ast = Inject.leftInjectInstance

type F[a] = Free[Ast, a]
implicit val monad: MonadTell[F, String] = MonadTell.liftF
Expand Down
2 changes: 1 addition & 1 deletion example/src/main/scala/scalaz/example/KleisliUsage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object KleisliUsage {
Continent("Asia",
List(
Country("India",
List(City("New Dehli"), City("Calcutta"))))))
List(City("New Delhi"), City("Calcutta"))))))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proper name...


def continents(name: String): List[Continent] =
data.filter(k => k.name.contains(name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package scalaz.example
A rather contrived example which shows how ReaderWriterStateT could be used.
@author stew@vireo.org / stew@helloreverb.com

We create a simple langauage named CAB
We create a simple language named CAB
Strings in the CAB language is a series of A, B, or C tokens followed by a EOF:
<cab> ::= 'C' | 'A' | 'B'
<string> ::= <cab> <string> | '.'
Expand All @@ -28,7 +28,7 @@ case object B extends Token

object Token {

implicit val euqalsRef: Equal[Token] = Equal.equalRef
implicit val equalsRef: Equal[Token] = Equal.equalRef
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

implicit val showTok: Show[Token] = {
case A => Cord("A")
case B => Cord("B")
Expand Down
6 changes: 3 additions & 3 deletions site/src/main/tut/typeclass/Equal.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ A `Equal` must satisfy the following [laws](https://en.wikipedia.org/wiki/Identi
- Reflexivity:
- `x === x` for any `x`.
- The indiscernibility of identicals:
- For any `x` and `y`, if `x === y`, then `x` and `y` are indiscernable
- For any `x` and `y`, if `x === y`, then `x` and `y` are indiscernible
- The identity of indiscernibles:
- For any `x` and `y`, if `x` and `y` are indiscernable, then `x === y`
- For any `x` and `y`, if `x` and `y` are indiscernible, then `x === y`

*Indiscernability* formalizes the intuitive notion of two objects having the exact same properties. Two values `x, y: A` are indiscernable if there exists no function `f: A => Boolean` such that `f(x)` is `true` and `f(y)` is `false`.
*Indiscernibility* formalizes the intuitive notion of two objects having the exact same properties. Two values `x, y: A` are indiscernible if there exists no function `f: A => Boolean` such that `f(x)` is `true` and `f(y)` is `false`.

These laws entail symmetry and transitivity, which should be easier to test, since they don't universally quantify over all possible predicates in the language:

Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/scalaz/DListTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object DListTest extends SpecLite {
def monoid[A] = Monoid[DList[A]]
def monadPlus = MonadPlus[DList]
def alt = Alt[DList]
def bindrec = BindRec[DList]
def bindRec = BindRec[DList]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is the scariest (it occurs in three files).

I can't understand how this code could compile in both forms. Based on the surrounding code, this change appears to be correct, but 🤷 .

Copy link
Collaborator

@Atry Atry Feb 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just an unused method to test whether BindRec[DList] compiles or not. So any name would be OK.

def traverse = Traverse[DList]
def zip = Zip[DList]
def isEmpty = IsEmpty[DList]
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/scalaz/IListTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ object IListTest extends SpecLite {
def order[A: Order] = Order[IList[A]]
def monoid[A] = Monoid[IList[A]]
def monadPlus = MonadPlus[IList]
def bindrec = BindRec[IList]
def bindRec = BindRec[IList]
def traverse = Traverse[IList]
def zip = Zip[IList]
def align = Align[IList]
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/scalaz/LazyOptionTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object LazyOptionTest extends SpecLite {
def equal[A: Equal] = Equal[LazyOption[A]]
def monadPlus = MonadPlus[LazyOption]
def alt = Alt[LazyOption]
def bindrec = BindRec[LazyOption]
def bindRec = BindRec[LazyOption]
def cobind = Cobind[LazyOption]
def traverse = Traverse[LazyOption]
def zip = Zip[LazyOption]
Expand Down
8 changes: 4 additions & 4 deletions tests/src/test/scala/scalaz/ZipperTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,10 @@ object ZipperTest extends SpecLite {
}

"positions should return a zippers with all possible positions of a zipper" ! forAll { (z: Zipper[Int]) =>
val indeces = z.positions.map { _.index }.toLazyList
indeces.min must_===(0)
indeces.max must_===(z.length -1)
indeces.sorted must_===(indeces)
val indices = z.positions.map { _.index }.toLazyList
indices.min must_===(0)
indices.max must_===(z.length -1)
indices.sorted must_===(indices)
z.positions.map { _.toLazyList }.toLazyList.distinct.length must_===(1)
}

Expand Down
4 changes: 2 additions & 2 deletions tests/src/test/scala/scalaz/std/ListTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object ListTest extends SpecLite {
a.groupWhenM[Id](p).map(_.list.toList).flatten must_===(a)
}

"groupByWhenM[Id] ∀(i,j) | 0<i<resut.len & 0<j<result(i).len: p(result(i)(j), p(result(i)(j+1)) yields true" ! forAll {
"groupByWhenM[Id] ∀(i,j) | 0<i<result.len & 0<j<result(i).len: p(result(i)(j), p(result(i)(j+1)) yields true" ! forAll {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

(a: List[Int], p: (Int, Int) => Boolean) =>
a.groupWhenM[Id](p).forall { group =>
list.adjacentPairs(group.list.toList).forall(p.tupled)
Expand Down Expand Up @@ -88,7 +88,7 @@ object ListTest extends SpecLite {
a.groupWhen(p).map(_.list.toList).flatten must_===(a)
}

"groupByWhen ∀(i,j) | 0<i<resut.len & 0<j<result(i).len: p(result(i)(j), p(result(i)(j+1)) yields true" ! forAll {
"groupByWhen ∀(i,j) | 0<i<result.len & 0<j<result(i).len: p(result(i)(j), p(result(i)(j+1)) yields true" ! forAll {
(a: List[Int], p: (Int, Int) => Boolean) =>
a.groupWhen(p).forall { group =>
list.adjacentPairs(group.list.toList).forall(p.tupled)
Expand Down