Skip to content

1.9.0

Choose a tag to compare

@reid-spencer reid-spencer released this 14 Feb 17:09
· 1443 commits to main since this release
67a3f1f

RiddlResult[T] ADT

New cross-platform sealed trait RiddlResult[T] replaces Either[Messages, T] as the return type for all RiddlLib methods.

Changes

  • RiddlResult[T] sealed trait with Success[T] and Failure cases
    • map, flatMap for chaining operations
    • toEither for backward compatibility with existing Scala code
    • fromEither factory for bridging parser results
  • ast2bast now returns RiddlResult[Array[Byte]] instead of silently returning empty array on failure
  • TypeScript: ParseResult<T> renamed to RiddlResult<T> across all method signatures
    • Deprecated ParseResult<T> type alias kept for migration

Migration

Scala: Replace result.isRight / result.isLeft with pattern matching:

RiddlLib.parseString(source) match
  case RiddlResult.Success(root) => // use root
  case RiddlResult.Failure(errors) => // handle errors

Or use result.toEither to convert back to Either[Messages, T].

TypeScript: Replace ParseResult<T> with RiddlResult<T> in type annotations. The deprecated alias will continue to work.