package uniform
- Alphabetic
- By Inheritance
- uniform
- ScalaVersionCompatibility
- TreeLikeInstances
- ToTreeLikeOps
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Package Members
- package validation
Validation and data transformation capabilities used in uniform.
Type Members
- case class AskListBuilder[A] extends Product with Serializable
- trait Converter[E[_], F[_], A] extends AnyRef
Provides a mechanism to convert between two higher kinded types.
Provides a mechanism to convert between two higher kinded types.
This is commonly used to interleave other types into an interpreted uniform journey (for example API calls returning a Future[A] could be mapped to WebMonad[Html, A] in an interpretation targetting WebMonad[Html, *]).
If the journey contains convert(x: E[A]) then there must be an implicit Converter[E, F, A] in scope when interpreting to the F higher kinded type.
The most general way is to use a natural transformation E ~> F (from all possible A convert E[A] to F[A]), which will be implicitly converted into an Converter as needed
The intermediate form is to use a function from E[A] => F[A], which is specific to the type A, and could differ from E[B] => F[B] in implementation. As with a natural transformation this will be converted as needed.
The least general form is to extend Converter, this makes it possible to change the way the conversion is handled by key as well as by datatype.
implicit val converter = new Converter[List, Option, Int] { def apply(key: String, in: () => List[Int]): Option[Int] = key match { case "reverse" => in().lastOption case _ => in().headOption } }
- Annotations
- @implicitNotFound()
- case class ErrorMsg(msg: String, args: Any*) extends Product with Serializable
an error, usually constructed into an ErrorTree to provide the paths to the fields where the errors occurred
an error, usually constructed into an ErrorTree to provide the paths to the fields where the errors occurred
val errorTree = ErrorMsg("myform.myfield.badinput").toTree
- type ErrorTree = ListMap[NonEmptyList[InputPath], NonEmptyList[ErrorMsg]]
- type Input = Map[InputPath, List[String]]
- type InputPath = List[String]
- case class InteractBuilder[A] extends Product with Serializable
- trait Interpreter[F[_], INTERACTTC[_, _], ASKLISTTC[_]] extends AnyRef
Maps a journey from its abstract form into a concrete one.
Maps a journey from its abstract form into a concrete one.
Must target a specific higher kinded type (for example, WebMonad).
When creating your own interpreter you may be better served by inheriting MonadInterpreter as this already has some of the wiring
- class InterpreterMacros extends AnyRef
- trait MonadInterpreter[F[_], INTERACTTC[_, _], ASKLISTTC[_]] extends Interpreter[F, INTERACTTC, ASKLISTTC]
- sealed trait Needs[-T, +A] extends AnyRef
- trait Noop[A] extends AnyRef
- implicit class RichErrorTree extends AnyRef
- implicit final class RichInput extends AnyVal
- trait ScalaVersionCompatibility extends AnyRef
- trait TreeLike[T] extends Serializable
Can be navigated like a tree.
Can be navigated like a tree. Has a
Value
at branches and leaves, and edges are labelled withKey
.- Annotations
- @implicitNotFound()
- trait TreeLikeInstances extends AnyRef
- class MapTree[K, V] extends TreeLike[Map[List[K], V]]
- Definition Classes
- TreeLikeInstances
- trait Uniform[-R <: Needs[_, _], -T, +A] extends AnyRef
- trait UniformMessages[A] extends AnyRef
A content bundle
A content bundle
Typically used for internationalisation but also for customisation of content on given steps of a user-journey.
This is modelled largely around the
Messages
object in the play framework - albeit with some extra capabilities (such as decomposition), but as such although it can take arguments (Any*
)it is not typesafe and has no way of knowing ahead-of-time if content is missing.Unlike play Messages however, UniformMessages are typed, can be mapped to different types and are also Monoids allowing them to be combined.
val m = UniformMessages.fromMap( Map("page1.field2.dateOfBirth" -> List("When were you born?"), "dateOfBirth" -> List("Date of birth")) ) scala> m.get("page1.field2.dateOfBirth") res1: Option[String] = Some(When were you born?) scala> m.decomposeOpt("dateOfBirth") res2: Option[String] = Some(Date of birth) scala> import cats.implicits._ scala> {m |+| UniformMessages.bestGuess}.apply("page1.step2.EnterYourBillingAddress") res3: String = Enter Your Billing Address scala> case class PoorMansHtml(value: String) defined class PoorMansHtml scala> m.map(PoorMansHtml) res4: ltbs.uniform.UniformMessages[PoorMansHtml] = ...
Value Members
- def ask[A](key: String, default: Option[A] = None, validation: Rule[A] = Rule.alwaysPass[A], customContent: Map[String, (String, List[Any])] = Map.empty)(implicit arg0: Tag[A]): Uniform[Interact[Unit, A], Unit, A]
- def askList[A](key: String, default: Option[List[A]] = None, validation: Rule[List[A]] = Rule.alwaysPass[List[A]]): AskListBuilder[A]
- def convert[F[_], A](action: => F[A])(implicit tagF: TagK[F], tagA: Tag[A]): Uniform[Convert[F, A], Unit, A]
- def convertWithKey[F[_], A](key: String)(action: => F[A])(implicit tagF: TagK[F], tagA: Tag[A]): Uniform[Convert[F, A], Unit, A]
- def end(key: String): Uniform[Interact[Unit, Nothing], Unit, Nothing]
- def end[A](key: String, value: A)(implicit arg0: Tag[A]): Uniform[Interact[A, Nothing], A, Nothing]
- def end(key: String, customContent: Map[String, (String, List[Any])]): Uniform[Interact[Unit, Nothing], Unit, Nothing]
- def end[T](key: String, value: T, customContent: Map[String, (String, List[Any])])(implicit arg0: Tag[T]): Uniform[Interact[T, Nothing], T, Nothing]
- def interact[A]: InteractBuilder[A]
- implicit def monListMap[K, V](implicit arg0: Semigroup[V]): Monoid[ListMap[K, V]] { def empty: scala.collection.immutable.ListMap[K,Nothing] }
- def nonReturn(key: String, hard: Boolean = true): NonReturn
- def pure[A](value: A): Uniform[Needs[_, _], Any, A]
- def subJourney[R <: Needs[_, _], T, A](pathHead: String, pathTail: String*)(base: Uniform[R, T, A]): Uniform[R, T, A]
- def tell[T](key: String, value: T, customContent: Map[String, (String, List[Any])] = Map.empty)(implicit arg0: Tag[T]): Uniform[Interact[T, Unit], T, Unit]
- implicit def toTreeLikeOps[T](target: T)(implicit tc: TreeLike[T]): Ops[T] { type TypeClassType = ltbs.uniform.TreeLike[T]{type Key = tc.Key; type Value = tc.Value} }
- Definition Classes
- ToTreeLikeOps
- Annotations
- @SuppressWarnings()
- object Converter
- implicit object Input extends MapTree[String, List[String]]
- object Needs
- object Noop
- object TreeLike extends Serializable
- implicit object ErrorTree extends TreeLike[ErrorTree]
- Definition Classes
- TreeLikeInstances
- object Uniform
- object UniformMessages