Eq package:rio

The Eq class defines equality (==) and inequality (/=). All the basic datatypes exported by the Prelude are instances of Eq, and Eq may be derived for any datatype whose constituents are also instances of Eq. The Haskell Report defines no laws for Eq. However, == is customarily expected to implement an equivalence relationship where two values comparing equal are indistinguishable by "public" functions, with a "public" function being one not allowing to see implementation details. For example, for a type representing non-normalised natural numbers modulo 100, a "public" function doesn't make the difference between 1 and 201. It is expected to have the following properties:
  • Reflexivity x == x = True
  • Symmetry x == y = y == x
  • Transitivity if x == y && y == z = True, then x == z = True
  • Substitutivity if x == y = True and f is a "public" function whose return type is an instance of Eq, then f x == f y = True
  • Negation x /= y = not (x == y)
Minimal complete definition: either == or /=.
O(n) Check if two vectors are equal. All Vector instances are also instances of Eq and it is usually more appropriate to use those. This function is primarily intended for implementing Eq instances for new vector types.
Equality of two FilePaths. If you call System.Directory.canonicalizePath first this has a much better chance of working. Note that this doesn't follow symlinks or DOSNAM~1s.
x == y ==> equalFilePath x y
normalise x == normalise y ==> equalFilePath x y
equalFilePath "foo" "foo/"
not (equalFilePath "foo" "/foo")
Posix:   not (equalFilePath "foo" "FOO")
Windows: equalFilePath "foo" "FOO"
Windows: not (equalFilePath "C:" "C:/")
O(n) Check if two vectors are equal using supplied equality predicate.
A Deque specialized to boxed vectors.
A double-ended queue supporting any underlying vector type and any monad. This implements a circular double-ended queue with exponential growth.
A Deque specialized to storable vectors.
A Deque specialized to unboxed vectors.
Helper function to assist with type inference, forcing usage of a boxed vector.
Helper function to assist with type inference, forcing usage of a storable vector.
Helper function to assist with type inference, forcing usage of an unboxed vector.
Convert a Deque into a list. Does not modify the Deque.
Convert to an immutable vector of any type. If resulting pure vector corresponds to the mutable one used by the Deque, it will be more efficient to use freezeDeque instead.

Example

>>> :set -XTypeApplications

>>> import qualified RIO.Vector.Unboxed as U

>>> import qualified RIO.Vector.Storable as S

>>> d <- newDeque @U.MVector @Int

>>> mapM_ (pushFrontDeque d) [0..10]

>>> dequeToVector @S.Vector d
[10,9,8,7,6,5,4,3,2,1,0]
Fold over a Deque, starting at the beginning. Does not modify the Deque.
Fold over a Deque, starting at the end. Does not modify the Deque.
Yield an immutable copy of the underlying mutable vector. The difference from dequeToVector is that the the copy will be performed with a more efficient memcpy, rather than element by element. The downside is that the resulting vector type must be the one that corresponds to the mutable one that is used in the Deque.

Example

>>> :set -XTypeApplications

>>> import qualified RIO.Vector.Unboxed as U

>>> d <- newDeque @U.MVector @Int

>>> mapM_ (pushFrontDeque d) [0..10]

>>> freezeDeque @U.Vector d
[10,9,8,7,6,5,4,3,2,1,0]
O(1) - Get the number of elements that is currently in the Deque
Create a new, empty Deque
Pop the first value from the end of the Deque
Pop the first value from the beginning of the Deque
Push a new value to the end of the Deque
Push a new value to the beginning of the Deque
The isSubsequenceOf function takes two lists and returns True if all the elements of the first list occur, in order, in the second. The elements do not have to occur consecutively. isSubsequenceOf x y is equivalent to elem x (subsequences y).

Examples

>>> isSubsequenceOf "GHC" "The Glorious Haskell Compiler"
True

>>> isSubsequenceOf ['a','d'..'z'] ['a'..'z']
True

>>> isSubsequenceOf [1..10] [10,9..0]
False