Represents the result of an action, which may be the result itself or an Invalid (error).
Represents the result of an action, which may be the result itself or an Invalid (error).
An unsafe operation may be attempted using Attempt.safe(unsafeCall)
for instance:
val r: Attempt[String] = for { a <- Attempt.safe { throw new RuntimeException("oh noes!") } b <- Attempt.ok("should be ok!") } yield b
will result in an Attempt that holds an Invalid.Err with the RuntimeException in it.
This class does not – and will not – auto-magically catch exceptions for you in map
/flatMap
.
1.2
ADT representing something invalid, may be a simple message or an exception.
ADT representing something invalid, may be a simple message or an exception.
Contains syntax for converting a String or Throwable into an Invalid, eg:
import Invalid.syntax val is: Invalid = "something went wrong".invalid val or: Invalid \/ Int = "oh noes!".invalidResult[Int] val nit: NonEmptyList[Invalid] = new IllegalStateException.invalidNel
Add syntax:
Add syntax:
coll.notEmpty: Option[CollType]
Add safe, total methods such as tailOption to anything Traversable
Add syntax:
Add syntax:
coll.tailOption: Option[CollType] coll.headTailOption: Option[(ElemType, CollType)]
Contains Base16 and Base32 (human-readable variant) encoding support, including as compile-time constants.
Contains Base16 and Base32 (human-readable variant) encoding support, including as compile-time constants. eg:
val a: BigInt = b16"ac60730edd01d21d3a367b638b5549c3b8fe2339" val b: BigInt = b32"G6VGHR3TTDMVIRZSMLQ2ABL4DZRS5WTX"
These will not compile if they contain incorrect characters for the encoding.