Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Explore additional Box combinators and hierarchical improvements

See original GitHub issue

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:

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]

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

Bhashitcommented, May 27, 2017

Alright. I think I’ll create a small WIP PR soon. Maybe you can comment on relevant parts, whether or not it’s what you expected and I’ll make the necessary changes. Hopefully that won’t be too much trouble for you. But do let me know if that doesn’t work for you.

Shadowfiendcommented, Jul 22, 2017

No, I think flip handles flipFailure just fine—it takes an EmptyBox, but if you want to pattern match inside it you can. I guess it won’t let you only flip a Failure… I would say it’s worth waiting to see if that’s a material use-case in practice though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · lift/framework - GitHub
#1995 opened on Jan 11 by mchwedczuk-box-com ... Explore additional Box combinators and hierarchical improvements. #1856 opened on May 22, ...
Read more >
US8666991B2 - Combinators to build a search engine
A method of counting items in a database system. The database system having nodes comprising processors and memory where the memory stores programs...
Read more >
Learning Programs: A Hierarchical Bayesian Approach
This paper explores the learning of a different but also important class of functions—those specified most nat- urally by computer programs. To motivate...
Read more >
Complex Selectors - Learn to Code Advanced HTML & CSS
Descendant selectors are created by spacing apart elements within a selector, creating a new level of hierarchy for each element list.
Read more >
Combinators for impure yet hygienic code generation
We present a code-combinator framework that lets us express arbitrary monadic effects, including mutable references and delimited control, that ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found