package util
Type classes and other utilities used by fs2.
Type Classes
This package includes a minimal set of common functional type classes -- e.g., Functor, Applicative, Monad, Traverse -- along with some extensions that are more specialized like Suspendable, Catchable, Effect, and Async.
Infix syntax is provided for all of these type classes by the fs2.util.syntax object, which is used by
adding import fs2.util.syntax._
. The infix syntax has no runtime cost. The type classes generally do
not define many derived methods (with the exception of Async
). Instead, derived methods are defined soley infix.
For example, Monad
does not define flatten
but monad infix syntax does.
Note that these type classes are intentionally minimal. Providing a general purpose set of functional structures is not a goal of FS2.
- Source
- util.scala
- Alphabetic
- By Inheritance
- util
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
trait
Applicative
[F[_]] extends Functor[F]
Applicative type class.
Applicative type class.
For infix syntax, including derived methods like
product
, importfs2.util.syntax._
. -
trait
Async
[F[_]] extends Effect[F]
Type class which describes effects that support asynchronous evaluation.
Type class which describes effects that support asynchronous evaluation.
Instances of this type class are defined by providing an implementation of
ref
, which allocates a mutable memory cell that supports various asynchronous operations.For infix syntax, import
fs2.util.syntax._
.- Annotations
- @implicitNotFound( ... )
-
type
Attempt[+A] = Either[Throwable, A]
Alias for
Either[Throwable,A]
. -
trait
Catchable
[F[_]] extends Monad[F]
Monad which tracks exceptions thrown during evaluation.
Monad which tracks exceptions thrown during evaluation.
For infix syntax, import
fs2.util.syntax._
. -
sealed abstract
class
Catenable
[+A] extends AnyRef
Trivial catenable sequence.
Trivial catenable sequence. Supports O(1) append, and (amortized) O(1)
uncons
, such that walking the sequence via N successiveuncons
steps takes O(N). Like a difference list, conversion to aStream[A]
takes linear time, regardless of how the sequence is built up. -
trait
Effect
[F[_]] extends Catchable[F] with Suspendable[F]
Monad which supports catching exceptions, suspending evaluation, and (potentially asynchronous) evaluation (i.e.
Monad which supports catching exceptions, suspending evaluation, and (potentially asynchronous) evaluation (i.e. extraction of a value).
For infix syntax, import
fs2.util.syntax._
. -
sealed
trait
Free
[+F[_], +A] extends AnyRef
A specialized free monad which captures exceptions thrown during evaluation.
-
trait
Functor
[F[_]] extends AnyRef
Functor type class.
Functor type class.
For infix syntax, including derived methods like
as
, importfs2.util.syntax._
. -
sealed
trait
Lub1
[-F[_], -G[_], +Lub[_]] extends AnyRef
Type operator that witnesses the least upper bound of type constructors
F
andG
.Type operator that witnesses the least upper bound of type constructors
F
andG
.Given a
Lub1[F,G,Lub]
,forall x
:Lub[x] >: F[x]
Lub[x] >: G[x]
- there is no
L[x]
for whichL[x] >: F[x]
andL[x] >: G[x]
andL[x] <: Lub[x]
-
trait
Monad
[F[_]] extends Applicative[F]
Monad type class.
Monad type class.
For infix syntax, including derived methods like
flatten
, importfs2.util.syntax._
. -
sealed
trait
RealSupertype
[-Sub, Super] extends AnyRef
Evidence that
A <: B
.Evidence that
A <: B
. This module provides implicitRealSupertype[Sub,Super]
only ifSuper
is not one of:Any
,AnyVal
,AnyRef
,Product
, orSerializable
.- Annotations
- @implicitNotFound( ... )
-
trait
RealType
[T] extends AnyRef
Evidence that
T
is notAny
. -
sealed
trait
Sub1
[-F[_], +G[_]] extends AnyRef
Evidence that
forall x . F[x] <: G[x]
-
trait
Suspendable
[F[_]] extends Monad[F]
Monad which supports capturing a deferred evaluation of a by-name
F[A]
.Monad which supports capturing a deferred evaluation of a by-name
F[A]
.Evaluation is suspended until a value is extracted, typically via the
unsafeRunAsync
method on the related Effect type class or via a type constructor specific extraction method (e.g.,unsafeRunSync
onTask
). Side-effects that occur while evaluating a suspension are evaluated exactly once at the time of extraction. -
trait
Traverse
[F[_]] extends Functor[F]
Traverse type class.
Traverse type class.
For infix syntax, import
fs2.util.syntax._
.For parallel traverse and sequence, see the Async type class.
-
trait
UF1
[-F[_], +G[_]] extends AnyRef
A
forall a . f a -> g a
.A
forall a . f a -> g a
. Aliased asF ~> G
. -
type
~>[-F[_], +G[_]] = UF1[F, G]
Operator alias for
UF1[F,G]
.
Value Members
- object Async
-
object
Attempt
Provides constructors for the
Attempt
alias. - object Catchable
- object Catenable
- object Free
- object Lub1 extends Lub1Instances1
-
object
NonFatal
Alternative to
scala.util.control.NonFatal
that only considersVirtualMachineError
s as fatal. - object RealSupertype extends NothingSubtypesItself
- object RealType extends RealTypeInstance
- object Sub1 extends Sub1Instances0
- object Traverse
- object UF1
-
object
syntax
Provides infix syntax for the typeclasses in the util package.