semagrams.util

package semagrams.util

Useful non-Semagrams-specific functionality

Attributes

Members list

Type members

Classlikes

object CustomAttr

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
CustomAttr.type
trait Described

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Action
trait PureAction
class AddAtMouse
class LensedVar[A, B](val v: UndoableVar[A], val l: Lens[A, B])

A view of a variable. Uses a lens to forward gets and sets to an underlying UndoableVar.

A view of a variable. Uses a lens to forward gets and sets to an underlying UndoableVar.

Note: this is specialized to UndoableVar right now because there isn't an informative superclass of both UndoableVar and Var. At some point we should fix this.

Maybe we should send a PR with UndoableVar and LensedVar to Laminar?

Attributes

Todo

implement more of the Var api.

Supertypes
class Object
trait Matchable
class Any
case object NoneError extends Exception

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
NoneError.type
object Path

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Path.type
case class Transform(z: Complex, w: Complex)

Represents an affine transformation of the 2d plane

Represents an affine transformation of the 2d plane

Value parameters

w

the translation factor Note: scaling is applied before translation.

z

the scaling/twisting factor

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Transform

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Transform.type
case class UndoState[A](recording: Boolean, past: List[A], present: A, future: List[A])

The internal state of an UndoableVar, implemented as a cursor into a list.

The internal state of an UndoableVar, implemented as a cursor into a list.

Value parameters

future

states that we have undone (for redo). This goes away once you start editing from a state in the past; we don't have undo trees yet.

past

previous states (for undoing)

present

current state

recording

indicator for whether we should record updates or not

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
class UndoableVar[A](init: A) extends SignalSource[A], Sink[A]

A class similar to Var but with support for undo and redo.

A class similar to Var but with support for undo and redo.

Attributes

Supertypes
trait Sink[A]
trait SignalSource[A]
trait Source[A]
class Object
trait Matchable
class Any
Show all
object complexattrs

Custom laminar attributes for using complex numbers with svg more easily

Custom laminar attributes for using complex numbers with svg more easily

These can be used both

  • with signals, i.e. xy <-- z,
  • with values, i.e. xy := z.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

def bijectiveRW[A](as: Iterable[A]): ReadWriter[A]
def boxSize(text: String, fontSize: Double): Complex

Returns the dimensions of the bounding box for text at fontSize

Returns the dimensions of the bounding box for text at fontSize

This caches computations, so that repeated queries are fast.

Attributes

Todo

we hardcode most of the style for this; we should make this more flexible.

def fromMaybe[Model, A](a: IO[Option[A]]): IO[A]

A convenience wrapper around calling unwrap for IO

A convenience wrapper around calling unwrap for IO

Attributes

def msgError(msg: String): RuntimeException
def wrappedHtml(el: Element, pos: Signal[Complex], dims: Signal[Complex]): ReactiveSvgElement[SVGElement]

Make an SVG element containing the html object.

Make an SVG element containing the html object.

We have to specify manually the dimensions and position of the html, because SVG does not have automatic layout (unlike html).

One way of getting "automatic layout" is to make an html element which takes up the entire semagrams window but is transparent and doesn't intercept mouse actions, and then doing layout within that.

Attributes

Extensions

Extensions

extension [A](action: IO[A])
def onCancelOrError(fin: IO[A]): IO[A]

Perform fin if the action is cancelled or errors.

Perform fin if the action is cancelled or errors.

Note that if the action is cancelled, it never returns, so we only get the result of fin if it errors.

Attributes

def toOption: IO[Option[A]]

Convert a possibly erroring IO action to one that safely returns an Option

Convert a possibly erroring IO action to one that safely returns an Option

Attributes

extension (elts: Seq[Element])
def toSvg: String

Produce an SVG string representing a whole path. Used in the d attribute.

Produce an SVG string representing a whole path. Used in the d attribute.

Attributes

extension [A, B](s: Signal[(A, B)])
def splitTuple: (Signal[A], Signal[B])
extension (t: Double)
def *(z: Complex): Complex

Multiplication by a complex implictly converts to complex

Multiplication by a complex implictly converts to complex

Attributes

def ^(x: Double): Double

Exponentiation as an infix operator

Exponentiation as an infix operator

Attributes

extension [A](x: Option[A])
def unwrap[F[_]](implicit F: MonadError[F, Throwable]): F[A]

Get the value of an option, throwing an error in a monad if the option is None. The advantage of throwing the error in the monad is that its more easily catchable.

Get the value of an option, throwing an error in a monad if the option is None. The advantage of throwing the error in the monad is that its more easily catchable.

Attributes

Exports

Defined exports

val cxy: CustomSvgAttr[Complex]
Exported from complexattrs

A custom svg attribute for setting cx and cy from one complex number

A custom svg attribute for setting cx and cy from one complex number

Attributes

Exported from complexattrs

A custom svg attribute for setting d (the svg element for describing a path) from a sequence of Path.Element.

A custom svg attribute for setting d (the svg element for describing a path) from a sequence of Path.Element.

Attributes

val pointsC: CustomSvgAttr[Seq[Complex]]
Exported from complexattrs

A custom svg attribute for setting points from a sequence of complex numbers

A custom svg attribute for setting points from a sequence of complex numbers

Attributes

val wh: CustomSvgAttr[Complex]
Exported from complexattrs

A custom svg attribute for setting w and h from one complex number

A custom svg attribute for setting w and h from one complex number

Attributes

val xy: CustomSvgAttr[Complex]
Exported from complexattrs

A custom svg attribute for setting x and y from one complex number

A custom svg attribute for setting x and y from one complex number

Attributes

val z1: CustomSvgAttr[Complex]
Exported from complexattrs

A custom svg attribute for setting x1 and y1 from a complex number

A custom svg attribute for setting x1 and y1 from a complex number

Attributes

val z2: CustomSvgAttr[Complex]
Exported from complexattrs

A custom svg attribute for setting x2 and y2 from a complex number

A custom svg attribute for setting x2 and y2 from a complex number

Attributes