trait MessageParser[A] extends AnyRef
MessageParser is a typeclass to simplify parsing messages. It can derive instances for any ADT, and makes it much easier to work with messages.
- A
The type to parse.
- Self Type
- MessageParser[A]
- Source
- MessageParser.scala
- Alphabetic
- By Inheritance
- MessageParser
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def parse[F[_]](implicit c: CacheSnapshot, F: Monad[F], E: ApplicativeHandle[F, String], S: MonadState[F, List[String]]): F[A]
A program to parse a message into the needed types.
Concrete Value Members
- def andThen[B](that: MessageParser[B]): MessageParser[(A, B)]
Runs another parser after this one.
- def collectWithError[B](error: String)(pf: PartialFunction[A, B]): MessageParser[B]
Apply a partial function of this parser, returning the error if the function isn't defined.
Apply a partial function of this parser, returning the error if the function isn't defined.
- B
The new parser type.
- error
The error to return if the partial function isn't defined.
- pf
The partial function to apply.
- def filterWithError(f: (A) => Boolean, error: String): MessageParser[A]
Create a new parser by filtering the values created by this parser.
Create a new parser by filtering the values created by this parser.
- f
The predicate.
- error
The error message if the value does not match the predicate.
- def orElse[B](that: MessageParser[B]): MessageParser[Either[A, B]]
Try another parser if this one fails.
- def orElseWith[B, C](that: MessageParser[B])(f: (Either[A, B]) => C): MessageParser[C]
Try another parser if this one fails, and combine their types.