我很想知道scala中子类型多态性的完整替代方法.
我在Camel的路径中使用日期:
fileName=${date:now:dd-MM-yyyy}
Run Code Online (Sandbox Code Playgroud)
但我现在需要的是 - 1天.那可能吗?
假设一个带有foo项目和bar项目的多项目SBT项目,这样foo项目依赖于bar-project代码等.
如果bar-project中的测试通过,我想在foo-project中进行测试.
怎么样?
我们的情况是两个依赖项具有完全相同的类(因为其中一个依赖项复制了它并包含在它们自己的源中).
这导致sbt assembly其重复数据删除检查失败.
如何从特定的jar中排除某个类?
尽管如此,sbt仍然抓住了lift-json.为什么?
"net.liftweb" %% "lift-mapper" % "2.6-M4" % "compile" excludeAll(ExclusionRule("net.liftweb", "lift-json"))
Run Code Online (Sandbox Code Playgroud)
更多信息.这是依赖树显示的内容:
+-net.liftweb:lift-mapper_2.10:2.6-M4
[info] | +-net.liftweb:lift-db_2.10:2.6-M4
[info] | | +-net.liftweb:lift-util_2.10:2.6-M4
[info] | | | |
…
[info] | | | |
[info] | | | +-net.liftweb:lift-json_2.10:2.6-M4
Run Code Online (Sandbox Code Playgroud)
所以依赖是lift-mapper - > lift-db - > lift-util - > lift-json,或许排除不深?
这基本上就是我想要的:
case class Foo[T](x: T)
object combine extends Poly {
implicit def caseFoo[A, B] = use((f1: Foo[A], f2: Foo[B]) => Foo((f1.x, f2.x)))
}
def combineHLatest[L <: HList](l: L) = l.reduceLeft(combine)
Run Code Online (Sandbox Code Playgroud)
所以combineHLatest(Foo(1) :: Foo("hello") :: HNil)应该屈服Foo( (1, "hello") )
上面没有编译,因为它找不到隐式的LeftReducer,但我不知道如何实现一个.
我们需要在编译步骤之后运行一些代码。在编译步骤之后让事情发生似乎很容易:
compile in Compile <<= (compile in Compile) map{x=>
// post-compile work
doFoo()
x
}
Run Code Online (Sandbox Code Playgroud)
但是你如何在新编译的代码中运行一些东西呢?
关于场景的更多信息:我们在提升项目中使用较少的 css。我们希望提升在运行中(如果需要)将较少的编译成 css 以帮助开发人员,但在构建期间、测试等运行之前使用相同的代码生成较少的代码。less-sbt 可能会有所帮助,但我们对如何解决这个问题很感兴趣。
考虑我需要使用的库的设计,无法修复:
trait Foo
class IgnoreMe extends Foo
class A extends Foo { def bar: A = ...}
class B extends Foo { def bar: B = ...}
Run Code Online (Sandbox Code Playgroud)
在我的代码中:
object Stuff {
type Barred = { def bar: Foo }
def doStuff(b:Barred) = b.bar
}
Run Code Online (Sandbox Code Playgroud)
这一切都很好,除了Stuff.doStuff将接受任何符合Barred类型的东西,而不仅仅是我想要的Foo的子类型.
我想定义Barred这样它既是Foo的子类型又有一个bar方法,我不能:(帮助赞赏.
在 emacs 中管理字体设置是否有任何标准技术、软件包等?
我想在某处定义默认的固定和可变宽度字体,并使用这些默认值在模式中设置人脸的字体。例如,将 org-mode 的默认字体设置为可变宽度默认值,并将其代码面设置为固定宽度默认值。
sbt ×5
scala ×5
apache-camel ×1
emacs ×1
inheritance ×1
polymorphism ×1
sbt-assembly ×1
shapeless ×1
subtype ×1
testing ×1
types ×1