Closed eparejatobes closed 7 years ago
I've managed to tweak local-implicits to generate val imports. This paves the way for the following
1
and _ × _
types, plus standard product morphisms/combinatorsf × g
as Syntax(f).×(g)
. Then syntax requires an implicit value of the corresponding type (cartesian category in this case)use the local import construct for providing scoped implicits and types. Possible syntax:
in(Scala.asDistCat) {
any( f × g, both(i, j) ) + h
}
// for a monad
in(FCMon.kleisli) {
(f >=> g) ⊗ h
}
// etc etc
The usability improvements this would bring are truly exciting.
Tests fail due to ohnosequences/local-imports#2.
After thinking about it, I don't like custom syntax. Inside each entity, we should provide
This simplifies the syntax architecture.
There will be some repetition in wiring implicits for nested components, but this only needs to be done once. I really like this approach.
This works nicely. I'll leave it unmerged for a while, just in case.
LGTM
Including how to better approach this, both from the user and library point of view.
There's no simple way of avoiding explicit imports, as the types depend on these values. The only approach that looks feasible is a compiler plugin in the spirit of local-implicits, which would add syntax for each sort of structure. We will need
This is too complex I think, and the improvement over an explicit import is not that significant. Just having something like this would be OK: