Explore additional Box combinators and hierarchical improvements
See original GitHub issueA few possibilities:
- Add
collect
toBox
. This can be useful forPartialFunction
-based combined filter+map operations on boxes as they are on collections. - Add some sort of
mapFailure
that behaves similarly tomap
but only runs with aFailure
. This would allow running a function only when the box is aFailure
, without having to do amatch
that has to deal with the other three box states. - Restructure the
Box
hierarchy a little to allow a type that indicates “onlyEmpty
orFull
” and another that indicates “onlyFailure
orFull
”, for example. - Add logging helpers for
Box
if possible (may need to be inlift-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:
- Created 6 years ago
- Comments:13 (13 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
No, I think
flip
handlesflipFailure
just fine—it takes anEmptyBox
, but if you want to pattern match inside it you can. I guess it won’t let you only flip aFailure
… I would say it’s worth waiting to see if that’s a material use-case in practice though.