我遇到了编写代理的问题,该代理可以从其创建者那里获取并传递抽象类型的成员。
trait Holder[A[_]] {
type I
type Y <: A[I]
}
trait Proxy[A[_], H <: Holder[A]] extends Holder[A] {
override type I = H#I
override type Y = H#Y
}
我收到了错误:
error: overriding type Y in trait Holder with bounds <: A[Proxy.this.I];
type Y has incompatible type
override type Y = H#Y
^
one error found
这是一个基本的scala限制,还是可能以某种方式被规避?
答案 0 :(得分:1)
您对shinyServer(function(input, output, session) {
output$table1 <- DT::renderDataTable({
search <- input$name
df <- subset(products, grepl(search, products$Name, ignore.case = TRUE)==TRUE)
df$Model <- paste0("<a href=",df$URL1,"target='_blank>",df$Model,"</a>")
df2 <- subset(df, Clonality == input$clonality)
df3 <- df2[,tbl]
datatable(df3, escape = FALSE)%>%formatStyle("Reviews",backgroundColor=styleInterval(1.10, c("red", "green")))%>%formatStyle("Name","Price Dollars",backgroundColor=styleEqual("132 214.5 264", "orange"))
})
output$table2 <- DT::renderDataTable({
search <- input$name
df <- subset(products, grepl(search, products$Name, ignore.case = TRUE)==TRUE)
df$Pathways <- paste0("<a href='",df$Pathway.URL.1,"' target='_blank'>",df$Pathways.1,"</a>", "</br>","<a href='",df$Pathway.URL.2,"' target='_blank'>",df$Pathways.2,"</a>")
df2 <- subset(df, Clonality == input$clonality)
df3 <- df2[,tbl2]
return(df3)
}, escape = FALSE)
table3 <- reactive({
search_topic <- input$name
search_query <- EUtilsSummary(search_topic, mindate = 2017, maxdate=2018, retmax = 100)
records <- EUtilsGet(search_query)
Titles <- as.data.frame(((ArticleTitle(records))))
colnames(Titles) = "Articles Titles"
withProgress(session, min=1, max=15, {
setProgress(message = 'Calculation in progress',
detail = 'This may take a while...')
for (i in 1:15) {
setProgress(value = i)
Sys.sleep(0.1)
}
})
print(Titles)
})
table4 <- reactive({
search_topic <- input$name
search_query <- EUtilsSummary(search_topic, mindate = 2017, maxdate=2018, retmax = 100)
records <- EUtilsGet(search_query)
AuthorList<-Author(records)
LastFirst<-sapply(AuthorList, function(x)paste(x$LastName,x$ForeName))
auths<-as.data.frame(sort(table(unlist(LastFirst)), dec=TRUE))
colnames(auths)<- c("Author", "Count")
auths <- cbind(Author = rownames(auths), auths)
rownames(auths) <- NULL
withProgress(session, min=1, max=15, {
setProgress(message = 'Calculation in progress',
detail = 'This may take a while...')
for (i in 1:15) {
setProgress(value = i)
Sys.sleep(0.1)
}
})
print(auths)
})
plot1 <- reactive({
search_topic <- input$name
search_query <- EUtilsSummary(search_topic, mindate = 2017, maxdate=2018, retmax = 1000)
records <- EUtilsGet(search_query)
y <- data.frame(cbind("year"= YearPubmed(records), "month"= MonthPubmed(records)))
date()
count<-table(y)
y$date <- as.Date(strptime(paste(y$year, y$month, "01", sep="-"), "%Y-%m-%d", tz = "UTC"), origin="1970-01-01")
withProgress(session, min=1, max=15, {
setProgress(message = 'Calculation in progress',
detail = 'This may take a while...')
for (i in 1:15) {
setProgress(value = i)
Sys.sleep(0.1)
}
})
y %>% group_by(date) %>% summarise(n.citation = length(date)) %>%
ggplot(aes(x=date, y = n.citation)) + geom_point(color="black", shape=20, alpha = 0.6) +
geom_line(color="black") +
ggtitle(input$name) + xlab("Date") + ylab("Number of Citations") + theme_bw() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"))
})
output$table5 <- DT::renderDataTable({
search <- input$model
df <- subset(products, products$Model==input$model)
df$Model <- paste0("<a href='",df$URL1,"' target='_blank'>",df$Model,"</a>")
df2 <- df[,tbl]
colnames(df2) <- c("Name", "Model", "Short Description", "Human Gene Symbol", "Sizes", "Price Pounds", "Price Dollars", "Price Euros", "Reviews" )
return(df2)
}, escape = FALSE)
output$table6 <- DT::renderDataTable({
search <- input$model
df <- subset(products, products$Model==input$model)
df$Pathways <- paste0("<a href='",df$Pathway.URL.1,"' target='_blank'>",df$Pathways.1,"</a>", "</br>","<a href='",df$Pathway.URL.2,"' target='_blank'>",df$Pathways.2,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.3,"' target='_blank'>",df$Pathways.2,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.4,"' target='_blank'>",df$Pathways.4,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.5,"' target='_blank'>",df$Pathways.5,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.6,"' target='_blank'>",df$Pathways.6,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.7,"' target='_blank'>",df$Pathways.7,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.8,"' target='_blank'>",df$Pathways.8,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.9,"' target='_blank'>",df$Pathways.9,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.10,"' target='_blank'>",df$Pathways.10,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.11,"' target='_blank'>",df$Pathways.11,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.12,"' target='_blank'>",df$Pathways.12,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.13,"' target='_blank'>",df$Pathways.13,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.14,"' target='_blank'>",df$Pathways.14,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.15,"' target='_blank'>",df$Pathways.15,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.16,"' target='_blank'>",df$Pathways.16,"</a>"
,"</a>", "</br>","<a href='",df$Pathway.URL.17,"' target='_blank'>",df$Pathways.17,"</a>")
df2 <- df[,tbl2]
return(df2)
}, escape = FALSE)
getPage<-function() {
search <- input$model
df <- subset(products, products$Model==input$model)
df$URL2 <- paste0("https://",df$URL1)
return(tags$iframe(src = df$URL2
, style="width:100%;", frameborder="0"
,id="iframe"
, height = "1000px", seamless = TRUE))
}
output$table3 <- renderTable(table3())
output$table4 <- renderTable(table4())
output$plot <- renderPlot(plot1(), width = 850, height = 425)
})
的定义意味着对于特定对象Holder
,您有h: Holder[A]
。
但这并不意味着每h.Y <: A[h.I]
H#Y <: A[H#I]
H <: Holder[A]
。我认为如果A
是协变的(因为你有h.Y <: A[h.I] <: A[H#I]
,那么所有h.Y
的常见超类型都是<: A[H#I]
)。