cps.monads.logic

Members list

Type members

Classlikes

class Choices[M[_]](using mc: CpsLogicMonadContext[M])

Should be used inside of reify block over CpsLogicMonad. Form mini-DSL after choice prefux

Should be used inside of reify block over CpsLogicMonad. Form mini-DSL after choice prefux

Attributes

Supertypes
class Object
trait Matchable
class Any
trait CpsConcurrentLogicMonad[M[_], F[_]] extends CpsLogicMonad[M]

Logic monad, where computation is done into known async concurrent monad F[_].

Logic monad, where computation is done into known async concurrent monad F[_].

Attributes

Supertypes
trait CpsLogicMonad[M]
trait CpsTryMonad[M]
trait CpsTrySupport[M]
trait CpsThrowMonad[M]
trait CpsThrowSupport[M]
trait CpsMonad[M]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Supertypes
trait CpsTryMonadContext[M]
trait CpsThrowMonadContext[M]
trait CpsMonadContext[M]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Supertypes
trait CpsLogicMonad[M]
trait CpsTryMonad[M]
trait CpsTrySupport[M]
trait CpsThrowMonad[M]
trait CpsThrowSupport[M]
trait CpsMonad[M]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Supertypes
trait CpsTryMonadContext[M]
trait CpsThrowMonadContext[M]
trait CpsMonadContext[M]
class Object
trait Matchable
class Any
Show all
trait CpsLogicMonad[M[_]] extends CpsTryMonad[M]

Typeclass for monad with backtracking logic operations. We can interpret it as a monad with non-deterministic choice or as a potentialy infinite stream of values corresponding to possible choices.

Typeclass for monad with backtracking logic operations. We can interpret it as a monad with non-deterministic choice or as a potentialy infinite stream of values corresponding to possible choices.

The default implementation is LogicStream (for no need in async operations) or LogicStreamT[F] (for need in async operations)

Attributes

Companion
object
Supertypes
trait CpsTryMonad[M]
trait CpsTrySupport[M]
trait CpsThrowMonad[M]
trait CpsThrowSupport[M]
trait CpsMonad[M]
class Object
trait Matchable
class Any
Show all
Known subtypes
object CpsLogicMonad

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait CpsLogicMonadContext[M[_]] extends CpsTryMonadContext[M]

Attributes

Supertypes
trait CpsTryMonadContext[M]
trait CpsThrowMonadContext[M]
trait CpsMonadContext[M]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Supertypes
trait CpsLogicMonad[M]
trait CpsTryMonad[M]
trait CpsTrySupport[M]
trait CpsThrowMonad[M]
trait CpsThrowSupport[M]
trait CpsMonad[M]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Supertypes
trait CpsTryMonadContext[M]
trait CpsThrowMonadContext[M]
trait CpsMonadContext[M]
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
trait CpsConcurrentLogicMonad[[A] =>> LogicStreamT[F, A], F]
trait CpsLogicMonad[[A] =>> LogicStreamT[F, A]]
trait CpsTryMonad[[A] =>> LogicStreamT[F, A]]
trait CpsTrySupport[[A] =>> LogicStreamT[F, A]]
trait CpsThrowMonad[[A] =>> LogicStreamT[F, A]]
trait CpsThrowSupport[[A] =>> LogicStreamT[F, A]]
trait CpsMonad[[A] =>> LogicStreamT[F, A]]
class Object
trait Matchable
class Any
Show all
trait CpsLogicStreamMonadBase[F[_]] extends CpsLogicMonad[[A] =>> LogicStreamT[F, A]]

Attributes

Supertypes
trait CpsLogicMonad[[A] =>> LogicStreamT[F, A]]
trait CpsTryMonad[[A] =>> LogicStreamT[F, A]]
trait CpsTrySupport[[A] =>> LogicStreamT[F, A]]
trait CpsThrowMonad[[A] =>> LogicStreamT[F, A]]
trait CpsThrowSupport[[A] =>> LogicStreamT[F, A]]
trait CpsMonad[[A] =>> LogicStreamT[F, A]]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Supertypes
trait CpsLogicStreamMonadBase[CpsIdentity]
trait CpsTryMonad[LogicStream]
trait CpsTrySupport[LogicStream]
trait CpsThrowMonad[LogicStream]
trait CpsThrowSupport[LogicStream]
trait CpsMonad[LogicStream]
class Object
trait Matchable
class Any
Show all
Self type

Attributes

Supertypes
trait CpsLogicMonad[[A] =>> LogicStreamT[F, A]]
trait CpsTryMonad[[A] =>> LogicStreamT[F, A]]
trait CpsTrySupport[[A] =>> LogicStreamT[F, A]]
trait CpsThrowMonad[[A] =>> LogicStreamT[F, A]]
trait CpsThrowSupport[[A] =>> LogicStreamT[F, A]]
trait CpsMonad[[A] =>> LogicStreamT[F, A]]
class Object
trait Matchable
class Any
Show all
trait CpsSyncLogicMonad[M[_]] extends CpsLogicMonad[M]

Attributes

Supertypes
trait CpsLogicMonad[M]
trait CpsTryMonad[M]
trait CpsTrySupport[M]
trait CpsThrowMonad[M]
trait CpsThrowSupport[M]
trait CpsMonad[M]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Supertypes
trait CpsSyncLogicMonad[LazyList]
trait CpsLogicMonad[LazyList]
trait CpsTryMonad[LazyList]
trait CpsTrySupport[LazyList]
trait CpsThrowMonad[LazyList]
trait CpsThrowSupport[LazyList]
trait CpsMonad[LazyList]
class Object
trait Matchable
class Any
Show all
Self type
object LogicStream

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait LogicStreamT[F[_], A]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Cons[F, A]
class Empty[F, A]
class Error[F, A]
class MPlusSeq[F, A]
class Pure[F, A]
class Suspend[F, A]
class WaitF[F, A]
Show all
object LogicStreamT

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Types

type LogicStream[A] = LogicStreamT[CpsIdentity, A]

Value members

Concrete methods

def all[M[_], A](collection: IterableOnce[A])(using m: CpsLogicMonad[M]): M[A]

Transform collection into logical stream, which include all elements.

Transform collection into logical stream, which include all elements.

Value parameters

collection
  • collection to transform
m
  • logical monad to use.

Attributes

def choices[M[_]](using mc: CpsLogicMonadContext[M]): Choices[M]

Should be used inside of reify block over CpsLogicMonad. Create a Choices instance, which can be used for 'injecting' value of collection into logical stream via mini-DSL.

Should be used inside of reify block over CpsLogicMonad. Create a Choices instance, which can be used for 'injecting' value of collection into logical stream via mini-DSL.

Value parameters

mc
  • monad context

Attributes

transparent inline def choicesFrom[M[_], A](collection: IterableOnce[A])(using mc: CpsLogicMonadContext[M]): A

Should be used inside of reify block over CpsLogicMonad. The next sequent code will be executed for all elements of collection

Should be used inside of reify block over CpsLogicMonad. The next sequent code will be executed for all elements of collection

Value parameters

collection
  • collection to iterate over
mc
  • monad context

Attributes

transparent inline def guard[M[_]](p: => Boolean)(using mc: CpsLogicMonadContext[M]): Unit

Should be used inside of reify block over CpsLogicMonad. The next sequent code will be executed only if p is true, otherwise the computation of the current value of logical stream will be terminated.

Should be used inside of reify block over CpsLogicMonad. The next sequent code will be executed only if p is true, otherwise the computation of the current value of logical stream will be terminated.

Value parameters

mc
  • monad context
p
  • predicate to check

Attributes

Givens

Extensions

Extensions

extension [M[_], A](ma: M[A])
def toLazyList: LazyList[A]
extension [M[_], A](ma: M[A])(using m: CpsLogicMonad[M])
def &>>[B](f: A => M[B]): M[B]

Synonym for 'fairFlatMap' or haskell >>-

Synonym for 'fairFlatMap' or haskell >>-

Attributes

Returns
  • stream, which contains values from ma and f applied to each value of ma in interleaved order.
See also

cps.monads.logic.CpsLogicMonad.fairFlatMap

def fairFlatMap[B](f: A => M[B]): M[B]

Version of flatMap, which interleave all results of ma (i.e. horizontal search instead of bfs).

Version of flatMap, which interleave all results of ma (i.e. horizontal search instead of bfs).

Value parameters

f
  • function to apply to each value of ma

Attributes

See also

cps.monads.logic.CpsLogicMonad.fairFlatMap

def filter(p: A => Boolean): M[A]

filter values, which satisfy predicate.

filter values, which satisfy predicate.

Attributes

transparent inline def ifThenElse[B](inline thenp: A => B)(inline elsep: => B): M[B]

CpsLogicMonad extension methods.

CpsLogicMonad extension methods.

Attributes

def ifThenElseM[B](thenp: A => M[B])(elsep: => M[B]): M[B]

If ma is note empty, then run thenp on it else elsep ,

If ma is note empty, then run thenp on it else elsep ,

Attributes

See also

cps.monads.logic.CpsLogicMonad.ifte

def observeN(n: Int): m.Observer[IndexedSeq[A]]

get first N values of computation, discarding all other.

get first N values of computation, discarding all other.

Value parameters

n
  • how many values to get

Attributes

Returns
  • sequence of values in observer monad
See also

cps.monads.logic.CpsLogicMonad.mObserveN

def observeOne: m.Observer[Option[A]]

get first value of computation.

get first value of computation.

Attributes

See also

cps.monads.logic.CpsLogicMonad.mObserveOne

def once: M[A]

retrieve only first value of computation.

retrieve only first value of computation.

Attributes

Returns
  • stream, which contains only first value of ma
See also

cps.monads.logic.CpsLogicMonad.once

def otherwise(thenp: => M[A]): M[A]

Run thenp if ma is empty.

Run thenp if ma is empty.

Attributes

See also

cps.monads.logic.CpsLogicMonad.otherwise

def |(mb: => M[A]): M[A]

interleave current computation with mb

interleave current computation with mb

Value parameters

mb

computation to interleave.

Attributes

Returns
  • stream, which contains values from ma and mb in interleaved order.
See also

cps.monads.logic.CpsLogicMonad.interleave

def |+|(mb: => M[A]): M[A]

Synonym for 'mplus'.

Synonym for 'mplus'.

Value parameters

mb
  • computation to add

Attributes

Returns
  • stream, which contains values from ma and when ma is exhaused - mb
See also

cps.monads.logic.CpsLogicMonad.mplus

def ||(mb: => M[A]): M[A]

Synonym for 'mplus'.

Synonym for 'mplus'.

Attributes

See also

cps.monads.logic.CpsLogicMonad.mplus