implicits for Box.forall

Showing 1-20 of 20 messages
implicits for Box.forall Vasya Novikov 12/16/13 11:22 PM
Hi all!
It is currently impossible to use Box.forall(...) If one tries to use
it, the compiler would say:

[error] Note that implicit conversions are not applicable because they
are ambiguous:
[error]  both method box2Iterable in trait BoxTrait of type [T](in:
net.liftweb.common.Box[T])Iterable[T]
[error]  and method box2Option in trait BoxTrait of type [T](in:
net.liftweb.common.Box[T])Option[T]
[error]  are possible conversion functions from myCustomVal.type to
?{def forall: ?}

I suggest to add this method to Box. (Method "exist" is already there
and works fine.)

The current workaround is:
     myBox.toIterable.forall(...)
Re: implicits for Box.forall Antonio Salazar Cardozo 12/17/13 9:55 AM
If you know it's a Box, why not use exists? They're functionally identical in the case of Boxes…
Thanks,
Antonio
Re: [Lift] Re: implicits for Box.forall Vasya Novikov 12/17/13 10:53 AM
The code gets cleaner this way:

     if (!myBox.exist(!_.hasSomething))

     if (myBox.forall(_.hasSomething))


On 2013-12-17 21:55, Antonio Salazar Cardozo wrote:
> If you know it's a Box, why not use exists? They're functionally
> identical in the case of Boxes�
> Thanks,
> Antonio
>
> On Tuesday, December 17, 2013 2:22:06 AM UTC-5, Vasya Novikov wrote:
>
>     Hi all!
>     It is currently impossible to use Box.forall(...) If one tries to use
>     it, the compiler would say:
>
>     [error] Note that implicit conversions are not applicable because
>     they
>     are ambiguous:
>     [error]  both method box2Iterable in trait BoxTrait of type [T](in:
>     net.liftweb.common.Box[T])Iterable[T]
>     [error]  and method box2Option in trait BoxTrait of type [T](in:
>     net.liftweb.common.Box[T])Option[T]
>     [error]  are possible conversion functions from myCustomVal.type to
>     ?{def forall: ?}
>
>     I suggest to add this method to Box. (Method "exist" is already there
>     and works fine.)
>
>     The current workaround is:
>          myBox.toIterable.forall(...)
>
> --
> --
> Lift, the simply functional web framework: http://liftweb.net
> Code: http://github.com/lift
> Discussion: http://groups.google.com/group/liftweb
> Stuck? Help us help you:
> https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Lift" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to liftweb+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Re: [Lift] Re: implicits for Box.forall Vasya Novikov 12/17/13 11:22 AM
Also,
     Empty.forall(...) must always yield "true"
while
     Empty.exist(...) must always yield "false"
Re: [Lift] Re: implicits for Box.forall fmpwizard 12/17/13 11:37 AM



On Tue, Dec 17, 2013 at 1:53 PM, Vasya Novikov <n1m5-goo...@yandex.ru> wrote:
The code gets cleaner this way:

    if (!myBox.exist(!_.hasSomething))

why are you double negating ?

see


val option = Some("diego").forall(x  => x.startsWith("d")  )
val box = Full("diego").exists(x  => x.startsWith("d")  )

both return true

Thanks 


 

    if (myBox.forall(_.hasSomething))



On 2013-12-17 21:55, Antonio Salazar Cardozo wrote:
If you know it's a Box, why not use exists? They're functionally identical in the case of Boxes…



--
Diego Medina
Lift/Scala consultant
di...@fmpwizard.com
http://fmpwizard.telegr.am
Re: [Lift] Re: implicits for Box.forall fmpwizard 12/17/13 12:02 PM
and if you really want to use forall, you can tell Scala to ignore one of the implicit conversion, like here


basically, if you define a method that has the same name as the implicit, but you don't make it implicit, it will cause scalac to ignore the implicit conversion.

Thanks

  Diego

Re: [Lift] Re: implicits for Box.forall Vasya Novikov 12/17/13 10:39 PM
If I don't double-negate -- I loose the behavior.
A box with a boolean can have 3 states:  empty, full(true), full(false)

box.forall yields:  true, true, false
box.exist yields:  false, true, false
!box.exist yields:  true, false, true
!box.exist(!) yields: true, true, false

So, you can't really emulate "forall" with "exist" until you use 2
negations. (Empty.forall returns true, Empty.exist returns false.)

About importing implicits -- thanks for the correction, that's a valid
option, too. Anyway, maybe adding such a method may not be a bad thing, too.

I'll make a pull-request if some of the commiters says "OK", of course.


On 2013-12-17 23:37, Diego Medina wrote:
>
>
>
> On Tue, Dec 17, 2013 at 1:53 PM, Vasya Novikov
> <n1m5-goo...@yandex.ru <mailto:n1m5-goo...@yandex.ru>> wrote:
>
>     The code gets cleaner this way:
>
>         if (!myBox.exist(!_.hasSomething))
>
>
> why are you double negating ?
>
> see
>
> http://www.scalakata.com/52b0a78ae4b0b1a1c4dbe2c6
>
> val option = Some("diego").forall(x  => x.startsWith("d")  )
> val box = Full("diego").exists(x  => x.startsWith("d")  )
>
> both return true
>
> Thanks
>
>
>
>         if (myBox.forall(_.hasSomething))
>
>
>
>     On 2013-12-17 21:55, Antonio Salazar Cardozo wrote:
>
>         If you know it's a Box, why not use exists? They're
>         functionally identical in the case of Boxes�
>         <mailto:liftweb%2B...@googlegroups.com>.
>         For more options, visit https://groups.google.com/groups/opt_out.
>
>
>     --
>     --
>     Lift, the simply functional web framework: http://liftweb.net
>     Code: http://github.com/lift
>     Discussion: http://groups.google.com/group/liftweb
>     Stuck? Help us help you:
>     https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
>     --- You received this message because you are subscribed to the
>     Google Groups "Lift" group.
>     To unsubscribe from this group and stop receiving emails from it,
>     send an email to liftweb+u...@googlegroups.com
>     <mailto:liftweb%2B...@googlegroups.com>.
>     For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> --
> Diego Medina
> Lift/Scala consultant
> di...@fmpwizard.com <mailto:di...@fmpwizard.com>
> http://fmpwizard.telegr.am
Re: [Lift] Re: implicits for Box.forall Antonio Salazar Cardozo 12/18/13 6:07 AM
Yep, valid, hadn't thought about it all the way through. If you can open that PR, it's a pretty targeted change. Please make sure to follow the instructions at the bottom of https://github.com/lift/framework/blob/master/CONTRIBUTING.md .
Thanks,
Antonio
Re: [Lift] Re: implicits for Box.forall Vasya Novikov 12/23/13 12:56 AM
Hello again. I wrote the `forall` method and some simple test. But the
thing is -- I can't work out how to launch tests. If I run the "test"
target -- the JVM gives OutOfMemory:


[info] Total for specification HtmlPropertiesSpec
[info] Finished in 58 ms
[info] 4 examples, 0 failure, 0 error
[info]
Exception in thread "pool-20-thread-2"
Exception: java.lang.OutOfMemoryError thrown from the
UncaughtExceptionHandler in thread "pool-20-thread-2"
[info] DB Specification
[info]
[info] DB should
[info] JsonParser Specification
[info]
[info] The JSON Parser should
[info] + parse very long strings without causing a stack overflow
[info] + multiple double quotes must parse
sbt appears to be exiting abnormally.
   The log file for this session is at /tmp/sbt8304078204217520190.log
Exception in thread "main"
Exception: java.lang.OutOfMemoryError thrown from the
UncaughtExceptionHandler in thread "main"


I tried to increase SBT limits to 8Gb, but it did not help.
What should I do? Launch only the test
"net.liftweb.common.BoxSpec.scala"? (How?) P-R without testing?

The code compiles successfully (2.10.3 and 2.9.1).
https://github.com/vn971/framework/commit/0f9b9b5ffaff16d9c0fc1b2f9f813701e31e492f
>     >         functionally identical in the case of Boxes�
>     <https://groups.google.com/groups/opt_out>.
>     >
>     >
>     >     --
>     >     --
>     >     Lift, the simply functional web framework: http://liftweb.net
>     >     Code: http://github.com/lift
>     >     Discussion: http://groups.google.com/group/liftweb
>     <http://groups.google.com/group/liftweb>
>     >     Stuck? Help us help you:
>     > https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>     <https://www.assembla.com/wiki/show/liftweb/Posting_example_code>
>     >
>     >     --- You received this message because you are subscribed to the
>     >     Google Groups "Lift" group.
>     >     To unsubscribe from this group and stop receiving emails
>     from it,
>     >     send an email to liftweb+u...@googlegroups.com
>     >     <mailto:liftweb%2B...@googlegroups.com>.
>     >     For more options, visit
>     https://groups.google.com/groups/opt_out
>     <https://groups.google.com/groups/opt_out>.
>     >
>     >
>     >
>     >
>     > --
>     > Diego Medina
>     > Lift/Scala consultant
>     > di...@fmpwizard.com <mailto:di...@fmpwizard.com>
>     > http://fmpwizard.telegr.am
>     > --
>     > --
>     > Lift, the simply functional web framework: http://liftweb.net
>     > Code: http://github.com/lift
>     > Discussion: http://groups.google.com/group/liftweb
>     <http://groups.google.com/group/liftweb>
>     > Stuck? Help us help you:
>     > https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>     <https://www.assembla.com/wiki/show/liftweb/Posting_example_code>
>     >
>     > ---
>     > You received this message because you are subscribed to the Google
>     > Groups "Lift" group.
>     > To unsubscribe from this group and stop receiving emails from
>     it, send
>     > an email to liftweb+u...@googlegroups.com.
>     > For more options, visit https://groups.google.com/groups/opt_out
>     <https://groups.google.com/groups/opt_out>.
Re: [Lift] Re: implicits for Box.forall fmpwizard 12/23/13 6:57 AM
how did you increase the memory on sbt? 8GB should be plenty to run the test (unless you are doing ++test.

What we normally do is only run test  from sbt, and then you may want  restart sbt and then use

++2.10.0

to switch to another scala version and then run test again, to make sure it works there too (and again for all the versions we build lift, which you can find on the build.sbt file.

Thanks

  Diego 

Re: [Lift] Re: implicits for Box.forall Vasya Novikov 12/23/13 10:56 AM
Diego, thank you very much! Indeed there was an issue with SBT
configuration. (The config was not read.)


On 2013-12-23 18:57, Diego Medina wrote:
> how did you increase the memory on sbt? 8GB should be plenty to run
> the test (unless you are doing ++test.
>
> What we normally do is only run test  from sbt, and then you may want
>  restart sbt and then use
>
> ++2.10.0
>
> to switch to another scala version and then run test again, to make
> sure it works there too (and again for all the versions we build lift,
> which you can find on the build.sbt file.
>
> Thanks
>
>   Diego
>
>
>
> On Mon, Dec 23, 2013 at 3:56 AM, Vasya Novikov
>         <mailto:n1m5-goo...@yandex.ru <mailto:n1m5-goo...@yandex.ru>>>
>         <mailto:liftweb%2Bu...@googlegroups.com>
>             >         <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252B...@googlegroups.com>>.
>             >         For more options, visit
>         https://groups.google.com/groups/opt_out
>             <https://groups.google.com/groups/opt_out>.
>
>             >
>             >
>             >     --
>             >     --
>             >     Lift, the simply functional web framework:
>         http://liftweb.net
>             >     Code: http://github.com/lift
>             >     Discussion: http://groups.google.com/group/liftweb
>             <http://groups.google.com/group/liftweb>
>             >     Stuck? Help us help you:
>             >
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>            
>         <https://www.assembla.com/wiki/show/liftweb/Posting_example_code>
>             >
>             >     --- You received this message because you are
>         subscribed to the
>             >     Google Groups "Lift" group.
>             >     To unsubscribe from this group and stop receiving emails
>             from it,
>             >     send an email to liftweb+u...@googlegroups.com
>         <mailto:liftweb%2Bu...@googlegroups.com>
>             >     <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252B...@googlegroups.com>>.
>             >     For more options, visit
>         https://groups.google.com/groups/opt_out
>             <https://groups.google.com/groups/opt_out>.
>
>             >
>             >
>             >
>             >
>             > --
>             > Diego Medina
>             > Lift/Scala consultant
>             > di...@fmpwizard.com <mailto:di...@fmpwizard.com>
>         <mailto:di...@fmpwizard.com <mailto:di...@fmpwizard.com>>
>             > http://fmpwizard.telegr.am
>             > --
>             > --
>             > Lift, the simply functional web framework:
>         http://liftweb.net
>             > Code: http://github.com/lift
>             > Discussion: http://groups.google.com/group/liftweb
>             <http://groups.google.com/group/liftweb>
>             > Stuck? Help us help you:
>             >
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>            
>         <https://www.assembla.com/wiki/show/liftweb/Posting_example_code>
>             >
>             > ---
>             > You received this message because you are subscribed to
>         the Google
>             > Groups "Lift" group.
>             > To unsubscribe from this group and stop receiving emails
>         from
>             it, send
>             > an email to liftweb+u...@googlegroups.com
>         <mailto:liftweb%2Bu...@googlegroups.com>.
>             > For more options, visit
>         https://groups.google.com/groups/opt_out
>             <https://groups.google.com/groups/opt_out>.
>
>
>         --
>         --
>         Lift, the simply functional web framework: http://liftweb.net
>         Code: http://github.com/lift
>         Discussion: http://groups.google.com/group/liftweb
>         Stuck? Help us help you:
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
>         ---
>         You received this message because you are subscribed to the
>         Google Groups "Lift" group.
>         To unsubscribe from this group and stop receiving emails from
>         it, send an email to liftweb+u...@googlegroups.com
>         <mailto:liftweb%2B...@googlegroups.com>.
>         For more options, visit https://groups.google.com/groups/opt_out.
>
>
>     --
>     --
>     Lift, the simply functional web framework: http://liftweb.net
>     Code: http://github.com/lift
>     Discussion: http://groups.google.com/group/liftweb
>     Stuck? Help us help you:
>     https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
>     --- You received this message because you are subscribed to the
>     Google Groups "Lift" group.
>     To unsubscribe from this group and stop receiving emails from it,
>     send an email to liftweb+u...@googlegroups.com
>     <mailto:liftweb%2B...@googlegroups.com>.
>     For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> --
> Diego Medina
> Lift/Scala consultant
> di...@fmpwizard.com <mailto:di...@fmpwizard.com>
> http://fmpwizard.telegr.am
> --
> --
> Lift, the simply functional web framework: http://liftweb.net
> Code: http://github.com/lift
> Discussion: http://groups.google.com/group/liftweb
Re: [Lift] Re: implicits for Box.forall fmpwizard 12/23/13 11:00 AM
Glad it is running  now
Re: [Lift] Re: implicits for Box.forall Vasya Novikov 12/23/13 11:34 AM
All tests successfully pass, with 2.10.0, 2.9.1, 2.9.1-1, 2.9.2.

I made a pull request: https://github.com/lift/framework/pull/1502


On 2013-12-23 18:57, Diego Medina wrote:
> how did you increase the memory on sbt? 8GB should be plenty to run
> the test (unless you are doing ++test.
>
> What we normally do is only run test  from sbt, and then you may want
>  restart sbt and then use
>
> ++2.10.0
>
> to switch to another scala version and then run test again, to make
> sure it works there too (and again for all the versions we build lift,
> which you can find on the build.sbt file.
>
> Thanks
>
>   Diego
>
>
>
> On Mon, Dec 23, 2013 at 3:56 AM, Vasya Novikov
>         <mailto:n1m5-goo...@yandex.ru <mailto:n1m5-goo...@yandex.ru>>>
>         <mailto:liftweb%2Bu...@googlegroups.com>
>             >         <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252B...@googlegroups.com>>.
>             >         For more options, visit
>         https://groups.google.com/groups/opt_out
>             <https://groups.google.com/groups/opt_out>.
>
>             >
>             >
>             >     --
>             >     --
>             >     Lift, the simply functional web framework:
>         http://liftweb.net
>             >     Code: http://github.com/lift
>             >     Discussion: http://groups.google.com/group/liftweb
>             <http://groups.google.com/group/liftweb>
>             >     Stuck? Help us help you:
>             >
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>            
>         <https://www.assembla.com/wiki/show/liftweb/Posting_example_code>
>             >
>             >     --- You received this message because you are
>         subscribed to the
>             >     Google Groups "Lift" group.
>             >     To unsubscribe from this group and stop receiving emails
>             from it,
>             >     send an email to liftweb+u...@googlegroups.com
>         <mailto:liftweb%2Bu...@googlegroups.com>
>             >     <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252B...@googlegroups.com>>.
>             >     For more options, visit
>         https://groups.google.com/groups/opt_out
>             <https://groups.google.com/groups/opt_out>.
>
>             >
>             >
>             >
>             >
>             > --
>             > Diego Medina
>             > Lift/Scala consultant
>             > di...@fmpwizard.com <mailto:di...@fmpwizard.com>
>         <mailto:di...@fmpwizard.com <mailto:di...@fmpwizard.com>>
>             > http://fmpwizard.telegr.am
>             > --
>             > --
>             > Lift, the simply functional web framework:
>         http://liftweb.net
>             > Code: http://github.com/lift
>             > Discussion: http://groups.google.com/group/liftweb
>             <http://groups.google.com/group/liftweb>
>             > Stuck? Help us help you:
>             >
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>            
>         <https://www.assembla.com/wiki/show/liftweb/Posting_example_code>
>             >
>             > ---
>             > You received this message because you are subscribed to
>         the Google
>             > Groups "Lift" group.
>             > To unsubscribe from this group and stop receiving emails
>         from
>             it, send
>             > an email to liftweb+u...@googlegroups.com
>         <mailto:liftweb%2Bu...@googlegroups.com>.
>             > For more options, visit
>         https://groups.google.com/groups/opt_out
>             <https://groups.google.com/groups/opt_out>.
>
>
>         --
>         --
>         Lift, the simply functional web framework: http://liftweb.net
>         Code: http://github.com/lift
>         Discussion: http://groups.google.com/group/liftweb
>         Stuck? Help us help you:
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
>         ---
>         You received this message because you are subscribed to the
>         Google Groups "Lift" group.
>         To unsubscribe from this group and stop receiving emails from
>         it, send an email to liftweb+u...@googlegroups.com
>         <mailto:liftweb%2B...@googlegroups.com>.
>         For more options, visit https://groups.google.com/groups/opt_out.
>
>
>     --
>     --
>     Lift, the simply functional web framework: http://liftweb.net
>     Code: http://github.com/lift
>     Discussion: http://groups.google.com/group/liftweb
>     Stuck? Help us help you:
>     https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
>     --- You received this message because you are subscribed to the
>     Google Groups "Lift" group.
>     To unsubscribe from this group and stop receiving emails from it,
>     send an email to liftweb+u...@googlegroups.com
>     <mailto:liftweb%2B...@googlegroups.com>.
>     For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> --
> Diego Medina
> Lift/Scala consultant
> di...@fmpwizard.com <mailto:di...@fmpwizard.com>
> http://fmpwizard.telegr.am
> --
> --
> Lift, the simply functional web framework: http://liftweb.net
> Code: http://github.com/lift
> Discussion: http://groups.google.com/group/liftweb
Re: [Lift] Re: implicits for Box.forall fmpwizard 12/23/13 11:40 AM
great, now, how do you normally handle this case:

"return true if the Box is empty, or if Box's value satisfies the predicate"

I know this is how forall in scala also works, but if I pass a predicate and the box is empty and I get true, isn't that kind of unexpected?

Thanks


Re: [Lift] Re: implicits for Box.forall Vasya Novikov 12/23/13 12:36 PM
I'd say it's okay and should be exactly so.
I take it as it is in math. "All crocodiles on moon are red" is true.
"All crocodiles on moon are blue" is also true. Or, generally speaking,
an empty set of elements satisfies all predicates.

The more intriguing thing is Failure().forall. One should understand
that using "forall" on an empty collection returns "true" on purpose.
But if that's TOO surprising -- it's OK for me to take back the PR.


On 2013-12-23 23:40, Diego Medina wrote:
> great, now, how do you normally handle this case:
>
> "return true if the Box is empty, or if Box's value satisfies the
> predicate"
>
> I know this is how forall in scala also works, but if I pass a
> predicate and the box is empty and I get true, isn't that kind of
> unexpected?
>
> Thanks
>
>
>
>
> On Mon, Dec 23, 2013 at 2:34 PM, Vasya Novikov
> <n1m5-goo...@yandex.ru <mailto:n1m5-goo...@yandex.ru>> wrote:
>
>     All tests successfully pass, with 2.10.0, 2.9.1, 2.9.1-1, 2.9.2.
>
>     I made a pull request: https://github.com/lift/framework/pull/1502
>
>
>
>     On 2013-12-23 18:57, Diego Medina wrote:
>
>         how did you increase the memory on sbt? 8GB should be plenty
>         to run the test (unless you are doing ++test.
>
>         What we normally do is only run test  from sbt, and then you
>         may want  restart sbt and then use
>
>         ++2.10.0
>
>         to switch to another scala version and then run test again, to
>         make sure it works there too (and again for all the versions
>         we build lift, which you can find on the build.sbt file.
>
>         Thanks
>
>           Diego
>
>
>
>         On Mon, Dec 23, 2013 at 3:56 AM, Vasya Novikov
>         <n1m5-goo...@yandex.ru
>         <mailto:n1m5-goo...@yandex.ru>
>                 <mailto:liftweb%2Bu...@googlegroups.com
>         <mailto:liftweb%252Bu...@googlegroups.com>>
>                     >         <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252B...@googlegroups.com>
>                 <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>>>.
>
>                     >         For more options, visit
>         https://groups.google.com/groups/opt_out
>                     <https://groups.google.com/groups/opt_out>.
>
>                     >
>                     >
>                     >     --
>                     >     --
>                     >     Lift, the simply functional web framework:
>         http://liftweb.net
>                     >     Code: http://github.com/lift
>                     >     Discussion:
>         http://groups.google.com/group/liftweb
>                     <http://groups.google.com/group/liftweb>
>                     >     Stuck? Help us help you:
>                     >
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>                          
>          <https://www.assembla.com/wiki/show/liftweb/Posting_example_code>
>                     >
>                     >     --- You received this message because you are
>                 subscribed to the
>                     >     Google Groups "Lift" group.
>                     >     To unsubscribe from this group and stop
>         receiving emails
>                     from it,
>                     >     send an email to
>         liftweb+u...@googlegroups.com
>         <mailto:liftweb%2Bu...@googlegroups.com>
>                 <mailto:liftweb%2Bu...@googlegroups.com
>         <mailto:liftweb%252Bu...@googlegroups.com>>
>                     >     <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252B...@googlegroups.com>
>                 <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>>>.
>                 <mailto:liftweb%2Bu...@googlegroups.com
>         <mailto:liftweb%252Bu...@googlegroups.com>>.
>
>                     > For more options, visit
>         https://groups.google.com/groups/opt_out
>                     <https://groups.google.com/groups/opt_out>.
>
>
>                 --         --         Lift, the simply functional web
>         framework: http://liftweb.net
>                 Code: http://github.com/lift
>                 Discussion: http://groups.google.com/group/liftweb
>                 Stuck? Help us help you:
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
>                 ---
>                 You received this message because you are subscribed
>         to the
>                 Google Groups "Lift" group.
>                 To unsubscribe from this group and stop receiving
>         emails from
>                 it, send an email to
>         liftweb+u...@googlegroups.com
>         <mailto:liftweb%2B...@googlegroups.com>
>                 <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252Bunsubscribe@googlegroups.com>>.
>
>                 For more options, visit
>         https://groups.google.com/groups/opt_out.
>
>
>             --     --     Lift, the simply functional web framework:
>         http://liftweb.net
>             Code: http://github.com/lift
>             Discussion: http://groups.google.com/group/liftweb
>             Stuck? Help us help you:
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
>             --- You received this message because you are subscribed
>         to the
>             Google Groups "Lift" group.
>             To unsubscribe from this group and stop receiving emails
>         from it,
>             send an email to liftweb+u...@googlegroups.com
>         <mailto:liftweb%2B...@googlegroups.com>
>             <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252Bunsubscribe@googlegroups.com>>.
>
>             For more options, visit
>         https://groups.google.com/groups/opt_out.
>
>
>
>
>         --
>         Diego Medina
>         Lift/Scala consultant
>         di...@fmpwizard.com <mailto:di...@fmpwizard.com>
>         <mailto:di...@fmpwizard.com <mailto:di...@fmpwizard.com>>
>
>         http://fmpwizard.telegr.am
>         --
>         --
>         Lift, the simply functional web framework: http://liftweb.net
>         Code: http://github.com/lift
>         Discussion: http://groups.google.com/group/liftweb
Re: [Lift] Re: implicits for Box.forall fmpwizard 12/23/13 12:46 PM



On Mon, Dec 23, 2013 at 3:36 PM, Vasya Novikov <n1m5-goo...@yandex.ru> wrote:
I'd say it's okay and should be exactly so.


Maybe my previous email wasn't clear. I didn't mean to question the PR or how you implemented it. 
 
I take it as it is in math. "All crocodiles on moon are red" is true. "All crocodiles on moon are blue" is also true. Or, generally speaking, an empty set of elements satisfies all predicates.


Let's try a different question, can you give a real use case where you use forall and having an Empty box is the same as having a Full box with the elements that you expect?

I was very surprised when I did

val x: Option[int] = None

x.forall(_ > 10)

and have that be true

Because the way I see it is, if my option is None, then it is not greater than 10, it is nothing. So, I definitely cannot use forall for validation, so I wonder where do people use forall

Thanks

  Diego

 

The more intriguing thing is Failure().forall. One should understand that using "forall" on an empty collection returns "true" on purpose. But if that's TOO surprising -- it's OK for me to take back the PR.


From Lift's point of view, a Failure is an Empty box with an explanation of why it is empty, so both should behave  the same way.

Thanks



--
Re: [Lift] Re: implicits for Box.forall Vasya Novikov 12/23/13 10:21 PM
My use case which made me start the topic:

* I have a cookie which "can hold" a date
* I want to set a new cookie, if it would not be older than the old one.

What I do now:
     if (S.cookie.toOption.forall(_ isOlder newDate)) { ... set new date }

In the same time, `S.cookie.exist(_ isOlder newDate)` would not allow an
empty (previous) cookie.


On 2013-12-24 00:46, Diego Medina wrote:
>
>
>
> On Mon, Dec 23, 2013 at 3:36 PM, Vasya Novikov
>                         <mailto:liftweb%2Bu...@googlegroups.com
>         <mailto:liftweb%252Bu...@googlegroups.com>
>                 <mailto:liftweb%252Bu...@googlegroups.com
>         <mailto:liftweb%25252Bu...@googlegroups.com>>>
>                             >        
>         <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252B...@googlegroups.com>
>                 <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>>
>                         <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>
>                 <mailto:liftweb%25252B...@googlegroups.com
>         <mailto:liftweb%2525252B...@googlegroups.com>>>>.
>                         <mailto:liftweb%2Bu...@googlegroups.com
>         <mailto:liftweb%252Bu...@googlegroups.com>
>                 <mailto:liftweb%252Bu...@googlegroups.com
>         <mailto:liftweb%25252Bu...@googlegroups.com>>>
>                             >    
>         <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252B...@googlegroups.com>
>                 <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>>
>                         <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>
>                 <mailto:liftweb%25252B...@googlegroups.com
>         <mailto:liftweb%2525252B...@googlegroups.com>>>>.
>                         <mailto:liftweb%2Bu...@googlegroups.com
>         <mailto:liftweb%252Bu...@googlegroups.com>
>                 <mailto:liftweb%252Bu...@googlegroups.com
>         <mailto:liftweb%25252Bu...@googlegroups.com>>>.
>
>
>                             > For more options, visit
>         https://groups.google.com/groups/opt_out
>                             <https://groups.google.com/groups/opt_out>.
>
>
>                         --         --         Lift, the simply
>         functional web
>                 framework: http://liftweb.net
>                         Code: http://github.com/lift
>                         Discussion: http://groups.google.com/group/liftweb
>                         Stuck? Help us help you:
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
>                         ---
>                         You received this message because you are
>         subscribed
>                 to the
>                         Google Groups "Lift" group.
>                         To unsubscribe from this group and stop receiving
>                 emails from
>                         it, send an email to
>         liftweb+u...@googlegroups.com
>         <mailto:liftweb%2B...@googlegroups.com>
>                 <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252Bunsubscribe@googlegroups.com>>
>                         <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252Bunsubscribe@googlegroups.com>
>                 <mailto:liftweb%252Bunsubscribe@googlegroups.com
>         <mailto:liftweb%25252Bunsubscribe@googlegroups.com>>>.
>
>
>                         For more options, visit
>         https://groups.google.com/groups/opt_out.
>
>
>                     --     --     Lift, the simply functional web
>         framework:
>         http://liftweb.net
>                     Code: http://github.com/lift
>                     Discussion: http://groups.google.com/group/liftweb
>                     Stuck? Help us help you:
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
>                     --- You received this message because you are
>         subscribed
>                 to the
>                     Google Groups "Lift" group.
>                     To unsubscribe from this group and stop receiving
>         emails
>                 from it,
>                     send an email to
>         liftweb+u...@googlegroups.com
>         <mailto:liftweb%2B...@googlegroups.com>
>                 <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252Bunsubscribe@googlegroups.com>>
>                     <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252Bunsubscribe@googlegroups.com>
>                 <mailto:liftweb%252Bunsubscribe@googlegroups.com
>         <mailto:liftweb%25252Bunsubscribe@googlegroups.com>>>.
>
>
>                     For more options, visit
>         https://groups.google.com/groups/opt_out.
>
>
>
>
>                 --         Diego Medina
>                 Lift/Scala consultant
>         di...@fmpwizard.com <mailto:di...@fmpwizard.com>
>         <mailto:di...@fmpwizard.com <mailto:di...@fmpwizard.com>>
>                 <mailto:di...@fmpwizard.com
>         <mailto:di...@fmpwizard.com> <mailto:di...@fmpwizard.com
>         <mailto:di...@fmpwizard.com>>>
>
>
>         http://fmpwizard.telegr.am
>                 --         --         Lift, the simply functional web
>         framework: http://liftweb.net
>                 Code: http://github.com/lift
>                 Discussion: http://groups.google.com/group/liftweb
Re: [Lift] Re: implicits for Box.forall fmpwizard 12/23/13 10:25 PM
thanks for the example, 
...
Re: [Lift] Re: implicits for Box.forall Vasya Novikov 1/15/14 9:26 AM
What about the `forall` method and some clean-ups?.. Are they rejected /
approved / postponed ?


On 2013-12-24 10:25, Diego Medina wrote:
> thanks for the example,
>
>
> On Tue, Dec 24, 2013 at 1:21 AM, Vasya Novikov
> <n1m5-goo...@yandex.ru <mailto:n1m5-goo...@yandex.ru>> wrote:
>
>     My use case which made me start the topic:
>
>     * I have a cookie which "can hold" a date
>     * I want to set a new cookie, if it would not be older than the
>     old one.
>
>     What I do now:
>         if (S.cookie.toOption.forall(_ isOlder newDate)) { ... set new
>     date }
>
>     In the same time, `S.cookie.exist(_ isOlder newDate)` would not
>     allow an empty (previous) cookie.
>
>
>     On 2013-12-24 00:46, Diego Medina wrote:
>
>
>
>
>         On Mon, Dec 23, 2013 at 3:36 PM, Vasya Novikov
>         <n1m5-goo...@yandex.ru
>         <mailto:n1m5-goo...@yandex.ru>
>                         <mailto:liftweb%252Bu...@googlegroups.com
>         <mailto:liftweb%25252Bu...@googlegroups.com>
>                 <mailto:liftweb%25252Bu...@googlegroups.com
>         <mailto:liftweb%2525252Bu...@googlegroups.com>>>>
>
>                                     >
>          <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252B...@googlegroups.com>
>                 <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>>
>                         <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>
>                 <mailto:liftweb%25252B...@googlegroups.com
>         <mailto:liftweb%2525252B...@googlegroups.com>>>
>                                
>         <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>
>                 <mailto:liftweb%25252B...@googlegroups.com
>         <mailto:liftweb%2525252B...@googlegroups.com>>
>                         <mailto:liftweb%25252B...@googlegroups.com
>         <mailto:liftweb%2525252B...@googlegroups.com>
>                 <mailto:liftweb%2525252B...@googlegroups.com
>         <mailto:liftweb%252525252B...@googlegroups.com>>>>>.
>         <mailto:liftweb%2Bu...@googlegroups.com
>         <mailto:liftweb%252Bu...@googlegroups.com>
>                 <mailto:liftweb%252Bu...@googlegroups.com
>         <mailto:liftweb%25252Bu...@googlegroups.com>>
>                         <mailto:liftweb%252Bu...@googlegroups.com
>         <mailto:liftweb%25252Bu...@googlegroups.com>
>                 <mailto:liftweb%25252Bu...@googlegroups.com
>         <mailto:liftweb%2525252Bu...@googlegroups.com>>>>
>
>                                     >          
>          <mailto:liftweb%2B...@googlegroups.com
>         <mailto:liftweb%252B...@googlegroups.com>
>                 <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>>
>                         <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>
>                 <mailto:liftweb%25252B...@googlegroups.com
>         <mailto:liftweb%2525252B...@googlegroups.com>>>
>                                
>         <mailto:liftweb%252B...@googlegroups.com
>         <mailto:liftweb%25252B...@googlegroups.com>
>                 <mailto:liftweb%25252B...@googlegroups.com
>         <mailto:liftweb%2525252B...@googlegroups.com>>
>                         <mailto:liftweb%25252B...@googlegroups.com
>         <mailto:liftweb%2525252B...@googlegroups.com>
>                 <mailto:liftweb%2525252B...@googlegroups.com
>         <mailto:liftweb%252525252B...@googlegroups.com>>>>>.
>         <mailto:liftweb%2Bu...@googlegroups.com
>         <mailto:liftweb%252Bu...@googlegroups.com>
>                 <mailto:liftweb%252Bu...@googlegroups.com
>         <mailto:liftweb%25252Bu...@googlegroups.com>>
>                         <mailto:liftweb%252Bu...@googlegroups.com
>         <mailto:liftweb%25252Bu...@googlegroups.com>
>                 <mailto:liftweb%25252Bu...@googlegroups.com
>         <mailto:liftweb%2525252Bu...@googlegroups.com>>>>.
>         <mailto:liftweb%252Bunsubscribe@googlegroups.com
>         <mailto:liftweb%25252Bunsubscribe@googlegroups.com>
>                 <mailto:liftweb%25252Bunsubscribe@googlegroups.com
>         <mailto:liftweb%2525252Bunsubscribe@googlegroups.com>>>>.
>         <mailto:liftweb%252Bunsubscribe@googlegroups.com
>         <mailto:liftweb%25252Bunsubscribe@googlegroups.com>
>                 <mailto:liftweb%25252Bunsubscribe@googlegroups.com
>         <mailto:liftweb%2525252Bunsubscribe@googlegroups.com>>>>.
>
>
>
>                             For more options, visit
>         https://groups.google.com/groups/opt_out.
>
>
>
>
>                         --         Diego Medina
>                         Lift/Scala consultant
>         di...@fmpwizard.com <mailto:di...@fmpwizard.com>
>         <mailto:di...@fmpwizard.com <mailto:di...@fmpwizard.com>>
>                 <mailto:di...@fmpwizard.com
>         <mailto:di...@fmpwizard.com> <mailto:di...@fmpwizard.com
>         <mailto:di...@fmpwizard.com>>>
>                         <mailto:di...@fmpwizard.com
>         <mailto:di...@fmpwizard.com>
>                 <mailto:di...@fmpwizard.com
>         <mailto:di...@fmpwizard.com>> <mailto:di...@fmpwizard.com
>         <mailto:di...@fmpwizard.com>
>                 <mailto:di...@fmpwizard.com
>         <mailto:di...@fmpwizard.com>>>>
>
>
>         http://fmpwizard.telegr.am
>                         --         --         Lift, the simply
>         functional web
>                 framework: http://liftweb.net
>                         Code: http://github.com/lift
>                         Discussion: http://groups.google.com/group/liftweb
>         <mailto:liftweb%252Bunsubscribe@googlegroups.com>>.
>             For more options, visit
>         https://groups.google.com/groups/opt_out.
>
>
>
>
>         --
>         Diego Medina
>         Lift/Scala consultant
>         di...@fmpwizard.com <mailto:di...@fmpwizard.com>
>         <mailto:di...@fmpwizard.com <mailto:di...@fmpwizard.com>>
>         http://fmpwizard.telegr.am
>         --
>         --
>         Lift, the simply functional web framework: http://liftweb.net
>         Code: http://github.com/lift
>         Discussion: http://groups.google.com/group/liftweb
>         Stuck? Help us help you:
>         https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
>         ---
>         You received this message because you are subscribed to the
>         Google Groups "Lift" group.
>         To unsubscribe from this group and stop receiving emails from
>         it, send an email to liftweb+u...@googlegroups.com
>         <mailto:liftweb%2B...@googlegroups.com>.
>         For more options, visit https://groups.google.co...
Re: [Lift] Re: implicits for Box.forall Antonio Salazar Cardozo 1/15/14 11:59 AM
I'll have a look this evening.
Thanks,
Antonio
...