refined icon indicating copy to clipboard operation
refined copied to clipboard

Some form of über-import to access standard functions in single line

Open benhutchison opened this issue 9 years ago • 3 comments

Some people (myself among them) prefer the simplicity of a blanket import to enable standard functionality, along the lines of import scalaz._; import Scalaz._.

As well as convenience and accessibility for newcomers ("just make it work"!), the other reason Ive come to appreciate them is I like to detect name clashes between libs I use early.

benhutchison avatar Jul 06 '16 10:07 benhutchison

I think it would make sense if the über-import would include everything in the refined package object, all predicates (that is boolean._ , char._, collection._, generic._, numeric._, and string._), auto._, types.all._, and api.Refined. This should include everything that is needed for "normal" usage of the library. Everything else is only needed if one wants to extend the library or define their own predicates.

fthomas avatar Dec 28 '16 21:12 fthomas

Maybe it can be divided into several über-imports, classified according to use.

  • Normal usage (import refined.normal) - What is stated above.
  • Advanced usage (import refined.advanced) - Normal + predicate extenders
  • Others... I don't know all the use cases, but I believe you can narrow them down.

soronpo avatar Dec 28 '16 22:12 soronpo

One step in this direction has been made in #433 which is now available in 0.9.0. So to import all predicates we can now import eu.timepit.refined.predicates.all._.

To import all of the standard functionality of the library we are now down to five imports:

import eu.timepit.refined._
import eu.timepit.refined.api.Refined
import eu.timepit.refined.auto._
import eu.timepit.refined.predicates.all._
import eu.timepit.refined.types.all._

My long-term goal is to shrink that further to maybe two or three imports.

fthomas avatar May 15 '18 08:05 fthomas