lift / lift/framework

Explore additional Box combinators and hierarchical improvements

Open
#1,856 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

A few possibilities:
- Add `collect` to `Box`. This can be useful for `PartialFunction`-based combined filter+map operations on boxes as they are on collections.
- Add some sort of `mapFailure` that behaves similarly to `map` but only runs with a `Failure`. This would allow running a function only when the box is a `Failure`, without having to do a `match` that has to deal with the other three box states.
- Restructure the `Box` hierarchy a little to allow a type that indicates “only `Empty` or `Full`” and another that indicates “only `Failure` or `Full`”, for example.
- Add logging helpers for `Box` if possible (may need to be in `lift-util`).

For the last one, an untested proposal I posted to gitter a while back:

```scala
sealed trait Box[+T]
sealed trait PresenceBox[+T] extends Box[T]
sealed trait TryBox[+T] extends Box[T]
sealed abstract class EmptyBox extends Box[Nothing] // Empty or Failure
case class Failure(msg: String, exception: PresenceBox[Throwable], chain: PresenceBox[Failure]) extends EmptyBox with TryBox[Nothing]
case object Empty extends EmptyBox with PresenceBox[Nothing]
case class Full[T](item: T) extends TryBox[T] with PresenceBox[T]
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing Box hierarchy and the PartialFunction-related behavior described in the issue, then inspect lift-util for the proposed logging helpers. Compare the collect, mapFailure, hierarchy, and logging proposals with the current Box API and discussion; the work is only done once a focused design and agreed scope are established.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.