以下功能-
mayBeMempty :: (Eq a, Semigroup a) => a -> a -> Bool
mayBeMempty candidate ref = candidate <> ref == ref
是Data.Set.isSubSetOf
的(效率较低)概括。它检查第二个参数中的第一个参数是否“包含”,并在第一个参数为True
时始终返回mempty
(当它返回False
时,它不是{{1 }}。
有人知道这个功能或概念是否已经以某种名称存在,或者甚至已经存在一个类型类(在这种情况下它的效率不会低于mempty
)?
答案 0 :(得分:0)
我已经在Hoogle中进行了搜索,并认为它没有预实现的版本。
我真的不知道如何提高效率,TBH。
答案 1 :(得分:0)
PartialOrd
的{{3}}是我想要的。
IIUC,不同之处在于,它不是按照我为Semigroup
所述的规则设计的,而是以与Lattice
相同的方式工作的,apply plugin: 'base'
apply plugin: 'application'
mainClassName = "sample.Sample"
def mainProjects = [':module-1',':module-2',':module-3',':module-4',':module-5',':module-6',':module-7',':module-8']
allprojects {
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: '../lib', include: ['test1.jar'])
compile fileTree(dir: '../lib', include: ['test-1.0.4.jar'])
compile fileTree(dir: '../lib', include: ['test2.jar'])
compile fileTree(dir: '../lib', include: ['test-0.7.12.jar'])
compile fileTree(dir: '../lib', include: ['mssql-jdbc-6.4.0.jre8.jar'])
compile fileTree(dir: '../lib', include: ['ojdbc6.jar'])
compile fileTree(dir: '../lib', include: ['ojdbc14.jar'])
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'log4j', name: 'log4j', version: '1.2.17'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.7'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.7'
}
task collectJars {
doLast {
copy{
into "../build/libs/"
from configurations.runtime
exclude('module-*.jar')
}
}
}
tasks.withType(Jar) {
manifest {
attributes(
'Implementation-Title': 'sample-jar',
'Implementation-Version': version,
'Provider' : "Test Technologies",
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}",
'Main-Class': 'sample.Sample',
'Class-Path': configurations.runtimeClasspath.files.collect { it.getName() }.join(' ') )
}
} build.dependsOn(collectJars)
}
task oneJar( type: Jar , dependsOn: mainProjects.collect{ it+":compileJava"})baseName = 'sample-jar' from files(mainProjects.collect{ project(it).sourceSets.main.output })
}
build.dependsOn(oneJar)
是在同一包中定义的,在某些方面类似于半群,但更适合诸如集合之类的东西,其中将某物与自身合并会导致自身。