Parseable

com.phasmidsoftware.gryphon.parse.Parseable
See theParseable companion trait
object Parseable

This object contains several implementations of the Parseable typeclass for specific types.

It provides implicit objects for parsing strings into common types, such as String, Int, and Double. These implementations can be used where implicit conversions are required for parsing operations.

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Parseable.type

Members list

Type members

Classlikes

Provides an implicit implementation of the Parseable typeclass for the Boolean type.

Provides an implicit implementation of the Parseable typeclass for the Boolean type.

This object defines a method to parse a String into a Boolean value using the toBooleanOption method. It is used as an implicit instance where the Parseable[Boolean] is required.

Parsing accepts strings like "true" or "false" (case-insensitive) and returns an Option containing the corresponding Boolean value if successful.

Extends the ParseableBoolean trait, which provides the parsing logic for the Boolean type.

Attributes

Companion
trait
Supertypes
trait Parseable[Boolean]
class Object
trait Matchable
class Any
Self type
trait ParseableBoolean extends Parseable[Boolean]

A trait that provides an implementation of the Parseable typeclass for the Boolean type.

A trait that provides an implementation of the Parseable typeclass for the Boolean type.

This trait defines a mechanism for parsing string representations of boolean values ("true" or "false") into corresponding Boolean objects. If the input string can be successfully converted into a boolean, the result is wrapped in Some. Otherwise, the result is None.

The parsing relies on the standard library method toBooleanOption to perform the string conversion, which is case-sensitive and adheres strictly to "true" and "false".

Attributes

Companion
object
Supertypes
trait Parseable[Boolean]
class Object
trait Matchable
class Any
Known subtypes

An implicit object that provides an implementation of the Parseable typeclass for Double.

An implicit object that provides an implementation of the Parseable typeclass for Double.

This allows strings to be parsed into Double values wherever an implicit Parseable[Double] instance is required, such as in parsing operations for graph edges or numerical data.

Attributes

Companion
trait
Supertypes
trait Parseable[Double]
class Object
trait Matchable
class Any
Self type
trait ParseableDouble extends Parseable[Double]

A trait that provides parsing functionality for strings into Double values.

A trait that provides parsing functionality for strings into Double values.

This trait extends the Parseable typeclass, specifically parameterized for Double. It includes a method for parsing strings into optional Double values.

Attributes

Companion
object
Supertypes
trait Parseable[Double]
class Object
trait Matchable
class Any
Known subtypes
object ParseableInt extends ParseableInt

An implicit object that provides a specific implementation of the Parseable[Int] typeclass. This object allows for parsing string inputs into optional integer values using the parse method.

An implicit object that provides a specific implementation of the Parseable[Int] typeclass. This object allows for parsing string inputs into optional integer values using the parse method.

It serves as an instance of the ParseableInt trait and automatically provides parsing capabilities for Int type values wherever an implicit Parseable[Int] is required.

The parsing functionality uses the toIntOption method for the conversion, which returns Some[Int] if the input string represents a valid integer, or None otherwise.

Attributes

Companion
trait
Supertypes
trait ParseableInt
trait Parseable[Int]
class Object
trait Matchable
class Any
Self type
trait ParseableInt extends Parseable[Int]

A trait that provides a specialized implementation of the Parseable typeclass for parsing strings into non-negative integer (Int) values.

A trait that provides a specialized implementation of the Parseable typeclass for parsing strings into non-negative integer (Int) values.

Classes or objects implementing this trait can parse a string input and convert it into an Option[Int], where Some(value) represents a successfully parsed integer, and None indicates a failed parsing attempt.

This trait extends Parseable[Int], inheriting its generic parsing behavior for the Int type.

Attributes

Companion
object
Supertypes
trait Parseable[Int]
class Object
trait Matchable
class Any
Known subtypes
object ParseableInt
object ParseableLong extends ParseableLong

An implicit object that provides an implementation of the Parseable typeclass for Long.

An implicit object that provides an implementation of the Parseable typeclass for Long.

Attributes

Companion
trait
Supertypes
trait Parseable[Long]
class Object
trait Matchable
class Any
Self type
trait ParseableLong extends Parseable[Long]

A trait that provides parsing functionality for strings into Long values.

A trait that provides parsing functionality for strings into Long values.

Attributes

Companion
object
Supertypes
trait Parseable[Long]
class Object
trait Matchable
class Any
Known subtypes
object ParseableLong

Provides an implicit implementation of the Parseable typeclass for the String type.

Provides an implicit implementation of the Parseable typeclass for the String type.

This object defines a mechanism for parsing a string input into an optional String value. It enables type-safe and consistent string parsing in contexts where the Parseable typeclass is used.

Attributes

Companion
trait
Supertypes
trait Parseable[String]
class Object
trait Matchable
class Any
Self type
trait ParseableString extends Parseable[String]

A trait that provides an implementation of the Parseable typeclass for the String type.

A trait that provides an implementation of the Parseable typeclass for the String type.

This trait allows parsing a string input into an optional value of type String. It is mainly used in contexts where type-safe and consistent string parsing is required.

Attributes

Companion
object
Supertypes
trait Parseable[String]
class Object
trait Matchable
class Any
Known subtypes
object ParseableUnit extends ParseableUnit

An implicit object that provides a Parseable implementation for the Unit type. This object enables parsing of strings into Unit values using the Parseable typeclass.

An implicit object that provides a Parseable implementation for the Unit type. This object enables parsing of strings into Unit values using the Parseable typeclass.

The parse method always returns Some(()) regardless of the input string, since Unit does not encode any meaningful data.

It is commonly used in scenarios where the parsing result itself is irrelevant, and only the fact that parsing occurred successfully matters.

Attributes

Companion
trait
Supertypes
trait Parseable[Unit]
class Object
trait Matchable
class Any
Self type
trait ParseableUnit extends Parseable[Unit]

A trait that provides a specific implementation of the Parseable typeclass for the Unit type.

A trait that provides a specific implementation of the Parseable typeclass for the Unit type.

This implementation of Parseable for Unit treats any input string as a valid parseable input and always returns Some(()), regardless of the content of the input string. Parsing inherently succeeds for this type since Unit carries no meaningful information.

This trait can be used wherever Parseable[Unit] is required to signify that parsing is always successful and does not depend on the input string.

This typeclass is defined as a trait, allowing it to be mixed into other components or implemented as an object.

Extends:

  • Parseable[Unit]: Defines the generic contract for parsing a string into a Unit value.

Methods:

  • parse(w: String): Option[Unit]: Always returns Some(()), ignoring the input string.

Use this implementation in contexts where parsing behavior is trivial and the result is guaranteed.

Attributes

Companion
object
Supertypes
trait Parseable[Unit]
class Object
trait Matchable
class Any
Known subtypes
object ParseableUnit

Value members

Concrete methods

def parser[T : Parseable]: String => T

Parses a string input into an instance of type T using the implicitly provided Parseable[T] typeclass. Utilizes the Parseable[T]#parse method to attempt parsing the input, throwing a ParseException with detailed information if the parsing fails.

Parses a string input into an instance of type T using the implicitly provided Parseable[T] typeclass. Utilizes the Parseable[T]#parse method to attempt parsing the input, throwing a ParseException with detailed information if the parsing fails.

Type parameters

T

The target type to which the string is parsed.

Attributes

Returns

A function that takes a String input and returns an instance of type T. If parsing fails, a ParseException is thrown.