2種類考えられる
- IO多重化(epoll/kqueue/etc..)
read(2)/write(2)が非同期
import java.util.List; | |
public class str { | |
private List<String> list; | |
private String suffix = "."; | |
public void someMethod(String s){} |
scala> class Bippy(xs: List[Int]) extends improving.TypesafeProxy(xs) { def isEmpty = true } | |
defined class Bippy | |
scala> val bippy = new Bippy(1 to 10 toList) | |
bippy: Bippy = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) | |
scala> bippy.slice(3, 7) | |
[proxy] $line4.$read.$iw.$iw.bippy.slice(3, 7) | |
res1: List[Int] = List(4, 5, 6, 7) |
package squeryl2scalikejdbc | |
import java.sql.{Types => JavaSqlTypes, Timestamp} | |
import org.squeryl.internals.{FieldMetaData, PosoMetaData} | |
import scalikejdbc.mapper.{Column, Table, CodeGenerator, GeneratorConfig} | |
object Main{ | |
type DataType = Int | |
type SquerylTable = org.squeryl.Table[_] |
JavaScript(記事ではnode.js)におけるコールバックを命令型、Promisesを関数型と捕らえ、node.jsの多くのAPI、モジュールがコールバックを利用している点が欠点となっている解説をしつつ、関数型のアプローチについて、Promisesを使ったアプローチの利点を紹介。
上記の記事に対して、node.jsのエコシステムの今を支えているのがコールバックではないかという反論。関数型アプローチに比べて命令型、コールバックをつかった場合は未来に発生するべき振る舞いをそれらしく表現できる点が多くのプログラマにとって理解しやすいという利点を紹介している。
import scalaz.BijectionT.<@> | |
object LensConverter{ | |
def shapeless2scalaz[A, B](shapelessLens: shapeless.Lens[A, B]): scalaz.Lens[A, B] = | |
scalaz.LensFamily.lensFamilyg(shapelessLens.set, shapelessLens.get) | |
def scalaz2shapeless[A, B](scalazLens: scalaz.Lens[A, B]): shapeless.Lens[A, B] = | |
new shapeless.Lens[A, B]{ |
import sbt._ | |
import Keys._ | |
object build extends Build{ | |
def github(org: String, name: String, hash: String): Project = Project( | |
name, file(name) | |
).settings( | |
baseSettings ++ seq( | |
sourceGenerators in Compile <+= (sourceManaged in Compile){ dir => task{ |
Original: "Callbacks are imperative, promises are functional: Node's biggest missed opportunity" by James Coglan
Translated by Yuta Okamoto (@okapies)
import scala.language.higherKinds | |
import scala.language.implicitConversions | |
import scala.language.reflectiveCalls | |
trait Forall[M[_]] { | |
def apply[A]: M[A] | |
} | |
object Maybe { |
/** | |
* Export the library classes globally. When no arguments are given, all classes defined in enchant.js as well as all classes defined in plugins will be exported. When more than one argument is given, by default only classes defined in enchant.js will be exported. When you wish to export plugin classes you must explicitly deliver the plugin identifiers as arguments. | |
*/ | |
declare module enchant { | |
declare function (); | |
declare function (moduleName:string); |