Skip to content

Instantly share code, notes, and snippets.

View gavinking's full-sized avatar
💭
Say more, more clearly, with @ceylon.

Gavin King gavinking

💭
Say more, more clearly, with @ceylon.
View GitHub Profile
@gavinking
gavinking / README.md
Last active October 17, 2016 07:18
Ceylon Web Runner: Ceylon Services

Ceylon Services Example

This tiny example demonstrates the use of Ceylon [service providers][] in the JavaScript environment. Service providers are an abstraction of, and [interoperate][] with, Java's [service loaders][], but are not tied to the Java platform, and can even work cross-platform.

@gavinking
gavinking / README.md
Last active February 7, 2018 09:42
Ceylon Web Runner: Records

Typesafe Records for Ceylon

The example demonstrates the use of Ceylon's powerful type system to define typesafe heterogenous maps, otherwise known as record types.

  • records.ceylon defines a tiny library for creating records
  • keys.ceylon defines example typesafe keys
@gavinking
gavinking / main.ceylon
Created December 1, 2016 20:53
Ceylon Web Runner: Converting JavaScript Date to Ceylon DateTime
import ceylon.time { Instant, DateTime }
shared void run() {
dynamic {
//create a JavaScript Date
dynamic date = Date();
print(date);
//convert it to a Ceylon DateTime
DateTime dt = Instant(date.getTime()).dateTime();
print(dt);
@gavinking
gavinking / proxy.ceylon
Last active December 6, 2016 19:13
Using Rank-2 polymorphic generic functions and JavaScript Proxy to create a typesafe proxy API for Ceylon objects
import ceylon.collection {
ArrayList
}
"Create a typesafe proxy for the given [[instance]], that
intercepts method calls and attribute evaluations."
Instance proxy<Instance>(Instance instance)(call, get) {
"Intercepts method invocations. Delegate to the method
of [[target]] by calling `method(args)`."
@gavinking
gavinking / README.md
Created August 13, 2017 14:56 — forked from ceylonwebide/README.md
Ceylon Web Runner: Solar System

Ceylon Solar System Example

This little example application demonstrates the use of Ceylon as an alternative to client-side JavaScript. In particular, the example shows:

  • a simple, typesafe, object-oriented program,
  • dependence on an external [cross-platform math module][xmath] written in Ceylon and hosted on