instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | package bank
import akka.actor.{ ActorSystem, Actor, Props, ActorRef }
import akka.dispatch.Future
import akka.pattern.pipe
case object Start
// Use bank.prop in the code or Bank() or Bank(-1)
// See http://doc.akka.io/docs/akka/snapshot/scala/actors.html#Recommended_Practices
object Bank {
def props(): Props = ... |
Explain and rewrite the following Scala code: | package util
import org.eclipse.jgit.api.Git
import util.Directory._
import util.StringUtil._
import util.ControlUtil._
import scala.collection.JavaConverters._
import org.eclipse.jgit.lib._
import org.eclipse.jgit.revwalk._
import org.eclipse.jgit.revwalk.filter._
import org.eclipse.jgit.treewalk._
import org.eclipse... |
Explain and rewrite the following Scala code: | /*
* Scala.js (https://www.scala-js.org/)
*
* Copyright EPFL.
*
* Licensed under Apache License 2.0
* (https://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
package org.scalajs.testsuite.javalib.util.fun... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | package com.jeff.chaser.builders
import com.badlogic.gdx.graphics.Pixmap.Format
import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.graphics.{Color, Pixmap, Texture}
import com.badlogic.gdx.math.MathUtils
object UtilBuilder {
private val thickness = 10
def makeDetectorCone(radius: Float,... |
Explain and rewrite the following Scala code: | package stagedparsec
import lms._
import lms.util._
import scala.lms.common._
import scala.lms.internal.GenericCodegen
import scala.reflect.SourceContext
import java.io.PrintWriter
/**
* A CPS encoding for Parse Results
* @see http://manojo.github.io/2015/09/02/staged-parser-combinators/ for more
* information.... |
Explain and rewrite the following Scala code: | package eu.henkelmann.actuarius
import org.scalatest.Matchers
import org.scalatest.FlatSpec
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
/**
* Tests the behavior of the complete parser, i.e. all parsing steps together.
*/
@RunWith(classOf[JUnitRunner])
class TransformerTest extends FlatSpe... |
Explain and rewrite the following Scala code: | package org.abhijitsarkar.akka.k8s.watcher.persistence
import java.util.UUID
import akka.actor.ActorSystem
import akka.stream.{ActorMaterializer, Materializer}
import akka.testkit.{TestKit, TestProbe}
import com.softwaremill.quicklens._
import com.typesafe.config.ConfigFactory
import de.flapdoodle.embed.process.runti... |
Explain and rewrite the following Scala code: | package distress
import dispatch.{ OkFunctionHandler, Http }
import com.ning.http.client.Response
import com.ning.http.client.filter.RequestFilter
/**
* A noop handler that simply tracks time in milliseconds. Requests
* that return a non-200 status response will throw a dispatch.StatusCode
* exception
*/
class Ti... |
Explain and rewrite the following Scala code: | package io.shaka.json
import scala.language.dynamics
object Json {
def apply(json: String) = new Json(try {
JsonParser.parse(json)
}
catch {
case e: Throwable => throw new BadJsonException(json, e)
})
}
class Json(val content: Any) extends Dynamic {
def selectDynamic(key: String): Json = {
def ... |
Explain and rewrite the following Scala code: | package aws.daleks.database
import com.amazonaws.regions.Region
import com.amazonaws.services.rds.AmazonRDSClient
import scala.collection.JavaConverters._
import com.amazonaws.services.rds.model.DBInstance
import com.amazonaws.services.rds.model.DeleteDBInstanceRequest
import rx.lang.scala._
import aws.daleks.RxDalek
... |
Explain and rewrite the following Scala code: | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may... |
Explain and rewrite the following Scala code: | package com.meteorcode.pathway.test
package tags
/**
* Created by hawk on 6/1/15.
*/
import org.scalatest.Tag
/**
* Tag for all tests that require access to the filesystem. These cannot be performed in
* some environments, so I figured that it would be best to preemptively tag them so that
* they can be excluded... |
Explain and rewrite the following Scala code: | /** MACHINE-GENERATED FROM AVRO SCHEMA. DO NOT EDIT DIRECTLY */
package other.ns.case
import org.apache.avro.Schema
import org.oedura.scavro.{AvroMetadata, AvroReader, AvroSerializeable}
import other.ns.{ExternalDependency => JExternalDependency}
final case class ExternalDependency(number: Int) extends AvroSerializ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2014 Commonwealth Computer Research, Inc.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicabl... |
Explain and rewrite the following Scala code: | package web.fruits;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.scalatest.{BeforeAndAfterAll, FlatSpec}
import org.openqa.selenium.phantomjs.PhantomJSDriver
;
/**
* Created by antoine on 3/23/14.
*/
class FruitsSpec extends Fla... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
Explain and rewrite the following Scala code: | package gg.uhc.hosts.endpoints
import akka.http.scaladsl.server.Rejection
case class DatabaseErrorRejection(cause: Throwable) extends Rejection
|
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2017 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or a... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.example.kestrel
import com.twitter.conversions.time._
import com.twitter.finagle.builder.ClientBuilder
import com.twitter.finagle.kestrel.protocol.Kestrel
import com.twitter.finagle.kestrel.{ReadHandle, Client}
import com.twitter.util.JavaTimer
import com.twitter.finagle.service.Backoff
imp... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or a... |
Explain and rewrite the following Scala code: | package uima.cr.ja
import java.io.File
import org.apache.uima.jcas.JCas
import org.apache.uima.resource.metadata.MetaDataObject
import us.feliscat.m17n.Japanese
import uima.cr.MultiLingualQuestionReader
import uima.rs.MultiLingualQuestion
import uima.rs.ja.JapaneseQuestion
import us.feliscat.text.StringOption
import ... |
Explain and rewrite the following Scala code: | package router
import model.User
import org.specs2.mock._
import org.specs2.mutable.Specification
import service.UserService
import spray.http.{ StatusCodes, BasicHttpCredentials }
import spray.httpx.SprayJsonSupport._
import spray.testkit.Specs2RouteTest
import utils.{ DatabaseSupportSpec, SpecSupport }
class UserI... |
Explain and rewrite the following Scala code: | package truerss.plugins
import com.github.truerss.base.{BaseContentPlugin, BaseFeedPlugin, _}
import com.typesafe.config.Config
import java.io.File
import java.net.URLClassLoader
import java.util.jar._
import scala.collection.mutable.ArrayBuffer
import scala.language.existentials
object PluginLoader {
import JarI... |
Explain and rewrite the following Scala code: | package mr.merc.util
object Divide {
implicit class DivideIntegral[T](i: T)(implicit num: Integral[T]) {
def divList(d: T): List[T] = {
val div = num.quot(i, d)
val rem = num.rem(i, d)
val list = List.fill(num.toInt(rem))(num.one) ::: List.fill(num.toInt(d) - num.toInt(rem))(num.zero)
... |
Explain and rewrite the following Scala code: | package com.bitmotif.part_1
object Listing_1_3_1 {
class Cafe {
def buyCoffee(cc: CreditCard): (Coffee, Charge) = {
val cup = new Coffee()
(cup, Charge(cc, cup.price))
}
def buyCoffees(cc: CreditCard, n: Int): (List[Coffee], Charge) = {
val purchases: List[(Coffee, Charge)] = List.fil... |
Explain and rewrite the following Scala code: | import java.io.FileNotFoundException
import com.toddschiller.sentry.{License, SoftGraph}
import com.toddschiller.sentry.maven.{MavenCrawler, Header}
import eu.fakod.neo4jscala.{Neo4jIndexProvider, RestGraphDatabaseServiceProvider, DatabaseServiceImpl, EmbeddedGraphDatabaseServiceProvider}
import scala.collection.mut... |
Explain and rewrite the following Scala code: | /** Copyright 2015 TappingStone, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law ... |
Explain and rewrite the following Scala code: | package db
import java.sql.Timestamp
import java.time.{ZoneOffset, ZonedDateTime}
import db.TypeConversions._
import shared.dto._
import shared.messages.{Language, Languages}
import shared.utils.StrUtils
import slick.jdbc.H2Profile.api._
import upickle.default._
trait HasId {
def id: Rep[Long]
}
trait HasOrder {
... |
Explain and rewrite the following Scala code: | package de.unihamburg.vsis.sddf.indexing
import org.apache.spark.rdd.RDD
import de.unihamburg.vsis.sddf.pipe.PipeElementPassthrough
import de.unihamburg.vsis.sddf.pipe.context.AbstractPipeContext
import de.unihamburg.vsis.sddf.pipe.context.CorpusContext
import de.unihamburg.vsis.sddf.pipe.context.GoldstandardContext
... |
Explain and rewrite the following Scala code: | package com.dominikgruber.fpinscala.chapter03
import org.scalatest._
class Exercise05Spec extends FlatSpec with Matchers {
"dropWhile" should "return Nil for an empty List" in {
List.dropWhile(Nil, (x: Nothing) => false) should be (Nil)
}
it should "drop all elements < 4 on List(1, 2, 3, 4, 5) " in {
... |
Explain and rewrite the following Scala code: | package services
import javax.inject.Inject
import dao.PersonDao
import models.Person
import play.api.libs.json.JsObject
import scala.concurrent.Future
class PersonService @Inject()(personDao: PersonDao) {
def findOne(selector: JsObject): Future[Option[Person]] = personDao.findOne(selector)
def findById(id: Lon... |
Explain and rewrite the following Scala code: | package controllers
import play.api._
import play.api.mvc._
import play.api.Play.current
import scala.xml._
import com.tinkerpop.blueprints.impls.orient.OrientGraph
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory
import scala.collection.JavaConverters._
import scala.collection.JavaConversions._
ob... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
Explain and rewrite the following Scala code: | package codeboy.mapreduce.simple
case class MapReduceRunner[mapInputValueType, mapOutPutKeyType, mapOutPutValueType, redeceOutPutValuetype](
jobName: String, inputFilePath: String,
inputReader: InputReader[mapInputValueType],
mapper: Mapper[mapInputValueType, mapOutPutKeyType, mapOutPutValueType],
reducer: Red... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | object SCL3455 {
trait T
val x: T = {
object a extends T
/*start*/a/*end*/ // Found Any, required T
}
}
//a.type |
Explain and rewrite the following Scala code: | // Copyright (c) 2016 Marco Marini, marco.marini@mmarini.org
//
// Licensed under the MIT License (MIT);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// Permission is hereby granted, free of charge, to any per... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | package inloopio.math.vector
/**
* A vector of real numbers.
*
* @author Caoyuan Deng
*/
trait Vec extends Cloneable {
/**
* The elements of this <code>Vec</code> as an <code>Array[double]</code>.
*
* @return the <code>Array[double]</code>
*/
def values: Array[Double]
def values_=(values: Array[D... |
Explain and rewrite the following Scala code: | package net.reduls.scala.gomoku.dic
object Morpheme {
private val idToMorps =
Util.withDictionaryDataWithCount("id-morphemes-map.bin", "morpheme.bin") {
(in1, surfaceIdLimit, in2, morphemeCount) =>
Array.tabulate(surfaceIdLimit)(_ =>
Array.tabulate(in1.readByte)(_ =>
encod... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2016 Language Technology Group and Interactive Graphics Systems Group, Technische Universität Darmstadt, Germany
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, ... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.codeInspection.methodSignature
import com.intellij.codeInspection.LocalInspectionTool
import com.intellij.testFramework.EditorTestUtil
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import org.jetbrains.plugins.scala.codeInspection.{ScalaInspectionBundle, ScalaQui... |
Explain and rewrite the following Scala code: | package ilc
package feature
package bags
import collection.immutable.HashMap
import collection.mutable.Stack
class LibraryHelper {
type Bag[T] = HashMap[T, Int]
//XXX: Could be made much faster by using builders (avoiding immutable
//copies), but this shouldn't be necessary.
def bagUnionInt[T](b1: Bag[T], b2... |
Explain and rewrite the following Scala code: | /**
* Copyright 2011 Harvey Harrison & Saem Ghani
*
* This file is part of GNCC.
*
* GNCC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later v... |
Explain and rewrite the following Scala code: | /*
* Copyright 2011-2022 GatlingCorp (https://gatling.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by appli... |
Explain and rewrite the following Scala code: | /*
* ____ ____ _____ ____ ___ ____
* | _ \\ | _ \\ | ____| / ___| / _/ / ___| Precog (R)
* | |_) | | |_) | | _| | | | | /| | | _ Advanced Analytics Engine for NoSQL Data
* | __/ | _ < | |___ | |___ |/ _| | | |_| | Copyright (C) 2010 - 2013 SlamData, In... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2014-2018 by The Monix Project Developers.
* See the project homepage at: https://monix.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache... |
Explain and rewrite the following Scala code: | /*
active-learning-scala: Active Learning library for Scala
Copyright (c) 2014 Davi Pereira dos Santos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
... |
Explain and rewrite the following Scala code: | package com.bwsw.cloudstack.pulse.validators.complex
import com.bwsw.cloudstack.pulse.validators.Validator
import com.bwsw.cloudstack.pulse.validators.primitive.{MACValidator, UUIDValidator}
/**
* Created by ivan on 28.07.17.
*/
class DiskRequestValidator extends Validator {
override protected def onError(para... |
Explain and rewrite the following Scala code: | package ir.ast
import ir.interpreter.Interpreter.ValueMap
import ir._
/**
* Tuple pattern.
* Code for this pattern can be generated.
*
* The tuple pattern has the following high-level semantics:
* <code>Tuple(2)(a, b) = (a, b)</code>
* The definitions for `n > 2` are accordingly.
*
* The tuple pattern has the... |
Explain and rewrite the following Scala code: | package at.logic.gapt.proofs
trait SequentProof[Formula, This <: SequentProof[Formula, This]] extends DagProof[This] { self: This =>
/**
* A list of SequentIndices denoting the main formula(s) of the rule.
*/
def mainIndices: Seq[SequentIndex]
/**
* The list of main formulas of the rule.
*/
def ma... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | package pregnaware.database.wrappers
import java.sql.Date
import java.time.LocalDate
import pregnaware.database.ConnectionManager._
import pregnaware.database.schema.Tables._
import slick.driver.MySQLDriver.api._
import scala.concurrent.Future
/** Due-date related functions */
trait DueDateWrapper extends CommonWra... |
Explain and rewrite the following Scala code: | import org.specs2.mutable._
import org.specs2.runner._
import org.junit.runner._
import play.api.test._
import play.api.test.Helpers._
@RunWith(classOf[JUnitRunner])
class IntegrationSpec extends Specification {
// Write application integration tests here
}
|
Explain and rewrite the following Scala code: | /*
* Copyright 2014-15 Intelix Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agr... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) Lightbend Inc. <https://www.lightbend.com>
*/
package play.sbt
import sbt._
import sbt.Keys._
import com.typesafe.sbt.packager.archetypes.JavaServerAppPackaging
import com.typesafe.sbt.jse.SbtJsTask
import play.core.PlayVersion
import play.sbt.routes.RoutesCompiler
import play.sbt.PlayImport.Play... |
Explain and rewrite the following Scala code: | /** Package to test the fpinscala.testing package
*
* Preliminary testing of the of the Gen case class
* in the fpinscala.testing package.
*/
package fpinscala.chap08.testing
import fpinscala.testing.{Gen, Prop}
import fpinscala.state.rand.{Rand, RNG, LCG}
import scala.util.{Try, Success, Failure}
import sca... |
Explain and rewrite the following Scala code: | /**
* (c) Copyright 2013 WibiData, Inc.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of... |
Explain and rewrite the following Scala code: | package controllers
import com.github.nscala_time.time.Imports._
import models.Events.eventWrites
import models.CalendarEvents.calendarEventWrites
import net.mtgto.garoon.Id
import net.mtgto.garoon.schedule.{CalendarEventService, EventId, EventRepository}
import play.api.libs.json.Json
import play.api.mvc.Controller
i... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | package tmc.CrafterTracker.domain
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers
import org.joda.time.DateTime
import tmc.BukkitTestUtilities.Services.TimeFreezeService
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import tmc.CrafterTracker.builders.aSession
// Cre... |
Explain and rewrite the following Scala code: | package com.twitter.finagle
import com.twitter.util.Duration
import java.net.SocketAddress
import org.junit.runner.RunWith
import org.mockito.Mockito.when
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
import org.scalatest.mock.MockitoSugar
@RunWith(classOf[JUnitRunner])
class ExceptionsTest ex... |
Explain and rewrite the following Scala code: | class A {
@deprecated def foo = 123
@deprecated def bar = 456
}
class B {
def foo = 123
@deprecated def bar = 456
}
|
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.tasty
import java.io.{BufferedInputStream, File, FileInputStream}
import java.nio.file.{Files, Paths}
import java.util.jar.JarInputStream
import scala.util.chaining.scalaUtilChainingOps
object Main {
enum Mode { case Parse, Test, Benchmark }
private val mode = Mode.Test
pri... |
Explain and rewrite the following Scala code: | /* Ayasdi Inc. Copyright 2015 - all rights reserved. */
/**
* @author abhishek, ajith, mohit
* big dataframe on spark: wrappers for python access via py4j
*/
package com.ayasdi.bigdf
import java.util.{ArrayList => JArrayList, HashMap => JHashMap, List => JList}
import scala.collection.JavaConversions._
imp... |
Explain and rewrite the following Scala code: | package testing.fixtures.different
import org.scalatest._
import java.io._
import collection.mutable.Map
class CallingLoanFixtureMethods extends FlatSpec {
def withFile(testCode: (File, FileWriter) => Any) {
val file = new File("trash/loan-pattern.txt")
val writer = new FileWriter(file, true)
try
... |
Explain and rewrite the following Scala code: | package paperdoll.core.layer
import shapeless.{ CNil, Coproduct, :+: }
import scala.annotation.implicitNotFound
/** Encapsulates an effect, represented as a functor-like type F[X]
* (Note that F does not necessarily need to be a Functor - the machinery
* will provide suitable map and flatMap operations).
* Cust... |
Explain and rewrite the following Scala code: | /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distribute... |
Explain and rewrite the following Scala code: | package org.johnstonshome.resteasy.scala
import scala.beans.{BeanProperty}
import java.util.Date
import javax.ws.rs.{ Path, GET, Produces }
abstract class BaseDate(@BeanProperty var format: String)
case class ADate(
@BeanProperty var id: String,
@BeanProperty var date: Date) extends BaseDate("simple")
case c... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2014-2019 Israel Herraiz <isra@herraiz.org>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, c... |
Explain and rewrite the following Scala code: | package edu.illinois.wala.classLoader
import edu.illinois.wala.Facade._
object ProgramCounter {
def apply(i: Int): Option[ProgramCounter] = try {
Some(new ProgramCounter(i))
} catch {
case e: IllegalArgumentException => None
}
} |
Explain and rewrite the following Scala code: | package models.persistance
import play.api.db.slick.Config.driver.simple._
import models.Sample
import models.TSVFileSampleLink
import models.TSVFileSampleLinkTable
import scala.collection.mutable.ListBuffer
object TSVFileSampleLinkDAO {
val tsvFileSampleLinks = TableQuery[TSVFileSampleLinkTable]
def getAllSa... |
Explain and rewrite the following Scala code: | //
// Copyright (c) 2015 IronCore Labs
//
package com.ironcorelabs.davenport
package util
import rx.lang.scala.{ Observable, Observer }
import scalaz.concurrent.Task
import scalaz.syntax.either._
import scalaz.\\/
final object observable { //scalastyle:ignore
case class NoElementInObservableException() extends Exc... |
Explain and rewrite the following Scala code: | package withOrb
import leon._
import mem._
import higherorder._
import lang._
import annotation._
import instrumentation._
import invariant._
import collection._
/**
* The running examples used in the paper
*/
object RunningExample {
sealed abstract class Bool
case class True() extends Bool
case class False(... |
Explain and rewrite the following Scala code: | package org.http4s
package object circe extends CirceInstances
|
Explain and rewrite the following Scala code: | /* __ *\\
** ________ ___ / / ___ __ ____ Scala.js Test Suite **
** / __/ __// _ | / / / _ | __ / // __/ (c) 2013, LAMP/EPFL **
** __\\ \\/ /__/ __ |/ /__/ __ |/_// /_\\ \\ http://scala-js.org/ **
** /____/\\___/... |
Explain and rewrite the following Scala code: | /*******************************************************************************
* (C) Copyright 2015 ADP, LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.... |
Explain and rewrite the following Scala code: | package app.restlike.rtm
import server.ServiceFactory.rimServerActor
import app.restlike.common.Colours.customGrey
import app.restlike.common.Responder._
import app.restlike.common._
import app.server.ModelChanged
import net.liftweb.http._
import net.liftweb.json._
import server.ServiceFactory
object Controller {
p... |
Explain and rewrite the following Scala code: | package com.softwaremill.vesplar.config
trait AnalyzerConfig extends CassandraConfig with TwitterConfig |
Explain and rewrite the following Scala code: | package scalaxy.enums
import org.junit._
import org.junit.Assert._
object Fruits extends enum {
class Fruit(val cost: Int) extends value
// override type value = Fruit
object Banana extends Fruit(1)
object Orange extends Fruit(2)
object Apple extends Fruit(3)
}
// object Fruits extends enum()(new EnumValu... |
Explain and rewrite the following Scala code: | package service
import model.PersonDao
import model.DogDao
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import model.{Person => DaoPerson, Dog => DaoDog}
import scala.util.{Try, Failure, Success}
trait WithAge{val age:Int}
case class Person(name:String, age:Int) extends Wi... |
Explain and rewrite the following Scala code: | package com.harrys.tables
import org.jooq._
import org.jooq.impl.UpdatableRecordImpl
import scala.util.Try
/**
* Created by jpetty on 11/10/15.
*/
trait AbstractTable[R <: UpdatableRecordImpl[R]]{
// Path-dependent type that allows defining result types more easily
type RecordType = R
// Path-dependent... |
Explain and rewrite the following Scala code: | package ru.dgolubets.reactjs.server.util
import java.io.File
import java.nio.file.ClosedWatchServiceException
import scala.concurrent.ExecutionContext
import better.files.FileMonitor
/**
* FileMonitor with some fixes
*/
private[server] class FileMonitorEx(root: File, recursive: Boolean = true)
extends FileMon... |
Explain and rewrite the following Scala code: | package mesosphere.marathon
import java.util.concurrent.CountDownLatch
import java.util.concurrent.atomic.AtomicBoolean
import java.util.{ Timer, TimerTask }
import javax.inject.{ Inject, Named }
import akka.actor.{ ActorRef, ActorSystem }
import akka.event.EventStream
import akka.pattern.{ after, ask }
import akka.u... |
Explain and rewrite the following Scala code: | package com.olegych.scastie
import java.security.{SecurityPermission, Permission}
import java.io.{File, FilePermission}
import java.util.PropertyPermission
/**
*/
object ScriptSecurityManager extends SecurityManager {
System.setProperty("actors.enableForkJoin", false + "")
private val lock = new Object
@vola... |
Explain and rewrite the following Scala code: | // Copyright: 2010 - 2017 https://github.com/ensime/ensime-server/graphs
// License: http://www.gnu.org/licenses/gpl-3.0.en.html
package org.ensime.indexer
import java.util
import scala.collection.JavaConverters._
import scala.collection.immutable.Queue
import scala.util._
import akka.event.slf4j.SLF4JLogging
import... |
Explain and rewrite the following Scala code: | package com.github.j5ik2o.spetstore
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.server.Directives._
import akka.stream.Materializer
import scala.concurrent.ExecutionContext
trait Route extends SprayJsonSupport with CustomerRoute with ItemTypeRoute {
implicit val mate... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2017 Magomed Abdurakhmanov, Hypertino
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
package com.hypertino.hyperbus.model
import java.io... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2010 Orbeon, Inc.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
*
* This program i... |
Explain and rewrite the following Scala code: | package lila.game
import chess.Color.{ White, Black }
import chess.format.Uci
import chess.Pos.piotr, chess.Role.forsyth
import chess.variant.{ Variant, Crazyhouse }
import chess.{ History => ChessHistory, CheckCount, Castles, Role, Board, MoveOrDrop, Pos, Game => ChessGame, Clock, Status, Color, Piece, Mode, Position... |
Explain and rewrite the following Scala code: | package chapter3
import scala.annotation.tailrec
object Chapter3 {
sealed trait List[+A]
case object Nil extends List[Nothing]
case class Cons[+A](head: A, tail: List[A] = Nil) extends List[A]
object List {
def sum(ints: List[Int]): Int = ints match {
case Nil => 0
case Cons(x, xs) => x + ... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2011-2022 GatlingCorp (https://gatling.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by appli... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.memcached.unit
import com.google.common.hash.Hashing
import com.twitter.conversions.time._
import com.twitter.finagle.memcached.protocol._
import com.twitter.finagle.memcached.util.AtomicMap
import com.twitter.finagle.memcached.{Entry, Interpreter}
import com.twitter.io.Buf
import com.twitt... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2016 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.persistence.cassandra.snapshot
import java.lang.{ Long => JLong }
import java.nio.ByteBuffer
import scala.collection.immutable
import scala.concurrent.Await
import scala.concurrent.Future
import akka.actor._
import akka.persistence._
i... |
Explain and rewrite the following Scala code: | package com.jwd.scala.sample.traitchain
object FileExample extends App {
new FileIterator("/Users/William/GitHub/learn-scala/learn-scala-sample/src/main/scala/traitchain/FileExample.scala").
foreach(line => println(line))
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.